python填表_小Python填表得到d
我正在嘗試使用Scrapy從網站自動下載數據。在
我要做的是:使用我的憑據登錄網站
通過在“RIC”行中寫入代碼并選擇感興趣的時段來選擇我想要的數據
單擊“獲取數據”后,將生成.csv文件,我可以從“下載/”url下載該文件,其中我的所有文件如下所示:
我可以使用“FormRequest”登錄。因此,我想做同樣的事情來填充“RIC”代碼并單擊“Get data”按鈕,但這失敗了。(我現在改變日期不是為了了解它的工作原理)
這里是我的代碼:class DmozSpider(scrapy.Spider):
name = "dmoz"
allowed_domains = ["myDomain"]
start_urls = [
"http://myDomain/dataServices/"
]
def parse(self, response):
return scrapy.FormRequest.from_response(
response,
formdata={'username': 'myName', 'password': 'myPass'},
callback=self.after_login
)
def after_login(self, response):
# check login succeed before going on
if "Your email adress and password did not match" in response.body:
print("\n\nFAIL\n\n")
self.logger.error("Login failed")
return
else:
print("\n\n LOGIN SUCCESSFUL \n\n")
filename = response.url.split("/")[-2] + '.html'
with open(filename, 'wb') as f:
f.write(response.body)
## THIS FAILS !!!
return scrapy.http.FormRequest.from_response(
response,
formxpath='//input[@value = ""]',
formdata={'value': 'DJ@'},
clickdata={'value': 'Get data'},
callback= self.foo
)
這是表單的html:
^{pr2}$
我從日志中得到的錯誤:2015-10-20 18:49:53 [scrapy] DEBUG: Retrying (failed 1 times): 500 Internal Server Error
2015-10-20 18:49:53 [scrapy] DEBUG: Retrying (failed 2 times): 500 Internal Server Error
2015-10-20 18:49:53 [scrapy] DEBUG: Gave up retrying (failed 3 times): 500 Internal Server Error
2015-10-20 18:49:53 [scrapy] DEBUG: Crawled (500) (referer: http://myDomain/dataServices/)
2015-10-20 18:49:53 [scrapy] DEBUG: Ignoring response <500 http://myDomain/dataServices/>: HTTP status code is not handled or not allowed
你知道我做錯了什么嗎?在
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的python填表_小Python填表得到d的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 二级建造师挂靠多少钱一年啊?
- 下一篇: gmc多少钱啊?