[英]How can i get the parsed html in scrapy from hardcoded url
令我措手不及的是,我只想將HTML響應放在自定義網址的變量中。
假設我有網址
url = "http://www.example.com"
現在我想獲取該頁面的html進行解析
pageHtml = scrapy.get(url)
我想要這樣的東西
page = urllib2.urlopen('http://yahoo.com').read()
我無法在搜尋器的上方使用的唯一問題是,我的會話已經通過scrapy進行了身份驗證,因此我無法使用任何其他函數來獲取該函數的html
我不希望在任何回調中響應,而只是直接在變量內部
基本上,您只需要添加相關導入即可使該問題中的代碼正常工作。 您還需要添加一個link
變量,該變量在示例代碼中已使用但未定義。
import httplib
from scrapy.spider import BaseSpider
from scrapy.http import TextResponse
bs = BaseSpider('some')
# etc
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.