我尝试使用scrapy来完成登录并收集我的项目提交计数.这是代码.
from scrapy.item import Item,Field
from scrapy.http import FormRequest
from scrapy.spider import Spider
from scrapy.utils.response import open_in_browser
class GitSpider(Spider):
name = "github"
allowed_domains = ["github.com"]
start_urls = ["https://www.github.com/login"]
def parse(self,response):
formdata = {'login': 'username','password': 'password' }
yield FormRequest.from_response(response,formdata=formdata,clickdata={'name': 'commit'},callback=self.parse1)
def parse1(self,response):
open_in_browser(response)
运行代码后
scrapy runspider github.py
它应该显示表单的结果页面,该页面应该是在同一页面中失败的登录页面,因为用户名和密码是假的.但是它显示了search page.日志文件位于pastebin
如何修复代码?提前致谢.
最佳答案
原文链接:https://www.f2er.com/python/438956.html