python - 使用 Scrapy + Python 使用未知令牌登录
问题描述
我正在尝试使用 Scrapy 向以下网页发出登录请求https://www.greatbuyproducts.com/scs/checkout.ssp?is=login&login=T&fragment=login-register#login-register
我在处理此网页的参数时遇到问题,因为我无法找到令牌,也许我必须生成它,但我不确定
这是我到目前为止的代码,问题是“令牌”部分应该在哪里。
class GreatBuy(scrapy.Spider):
name = "greatbuy"
start_urls = [
'https://www.greatbuyproducts.com/scs/checkout.ssp?is=login&login=T&fragment=login-register#login-register']
def parse(self, response):
token = # I don't know how to get it
yield scrapy.FormRequest('https://www.greatbuyproducts.com/scs/services/Account.Login.Service.ss?n=2&c=5237170', formdata={'''the token''', 'email': 'my@email.com', 'password': 'mypass', 'send': ''}, callback=self.starscraper)
def startscraper(self, response):
yield scrapy.Response('https://www.greatbuyproducts.com/', callback=self.verifylogin)
def verifylogin(self, response):
print(response.text)
我注意到查询字符串参数没有改变,我可以在这里使用它们吗?
解决方案
推荐阅读
- python - 结合几个热图
- sql - 在列值上连接两个表并根据其他列进行排序
- python - 使用本地 JSON 文件填充 Django DB
- django - 如何使 django url 动态化
- newrelic - 尽管从 New Relic 仪表板中可以看到服务器,但 REST API 未返回任何服务器
- ios - 使用通用可编码 API 客户端处理非 JSON 响应
- javascript - 如果索引大于使用 v-for 循环在 VUEJS 中的值,我如何显示(+10 多个)
- pycharm - PyCharm 的 Markdown 渲染很漂亮。有没有办法将它按原样保存到 pdf 或 html 文件中?
- string - 在golang中替换字符串中的一个字符
- uno-platform - 无法覆盖 OnApplyTemplate