#-*-coding:utf8-*- import requests from lxml import etree url = 'http://weibo.cn/u/xxxxxx' #此处请修改为微博地址 url_login = 'https://login.weibo.cn/login/' html = requests.get(url).content selector = etree.HTML(html) ####注意以下三个的内容会发生变化,在network中会发现,所以在登陆源码中能够查找到 password = selector.xpath('//input[@type="password"]/@name')[0] vk = selector.xpath('//input[@name="vk"]/@value')[0] action = selector.xpath('//form[@method="post"]/@action')[0] #print action #print password #print vk new_url = url_login + action #登陆请求的网址 data = { 'mobile' : '[email protected]', password : 'xxxxxxxx', ###变量 'remember' : 'on', 'backURL' : 'http://weibo.cn