python填表_小Python填表得到d
我正在嘗試使用Scrapy從網(wǎng)站自動下載數(shù)據(jù)。在
我要做的是:使用我的憑據(jù)登錄網(wǎng)站
通過在“RIC”行中寫入代碼并選擇感興趣的時段來選擇我想要的數(shù)據(jù)
單擊“獲取數(shù)據(jù)”后,將生成.csv文件,我可以從“下載/”url下載該文件,其中我的所有文件如下所示:
我可以使用“FormRequest”登錄。因此,我想做同樣的事情來填充“RIC”代碼并單擊“Get data”按鈕,但這失敗了。(我現(xiàn)在改變?nèi)掌诓皇菫榱肆私馑墓ぷ髟?
這里是我的代碼: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
你知道我做錯了什么嗎?在
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎總結(jié)
以上是生活随笔為你收集整理的python填表_小Python填表得到d的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 二级建造师挂靠多少钱一年啊?
- 下一篇: python编程制作接金币游戏_pyga