国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python使用scrapy解析js示例

2019-11-25 18:32:48
字體:
來源:轉載
供稿:網友

復制代碼 代碼如下:

from selenium import selenium

class MySpider(CrawlSpider):
    name = 'cnbeta'
    allowed_domains = ['cnbeta.com']
    start_urls = ['//m.survivalescaperooms.com']

    rules = (
        # Extract links matching 'category.php' (but not matching 'subsection.php')
        # and follow links from them (since no callback means follow=True by default).
        Rule(SgmlLinkExtractor(allow=('/articles/.*/.htm', )),
             callback='parse_page', follow=True),

        # Extract links matching 'item.php' and parse them with the spider's method parse_item
    )

    def __init__(self):
        CrawlSpider.__init__(self)
        self.verificationErrors = []
        self.selenium = selenium("localhost", 4444, "*firefox", "http://m.survivalescaperooms.com")
        self.selenium.start()

    def __del__(self):
        self.selenium.stop()
        print self.verificationErrors
        CrawlSpider.__del__(self)


    def parse_page(self, response):
        self.log('Hi, this is an item page! %s' % response.url)
        sel = Selector(response)
        from webproxy.items import WebproxyItem

        sel = self.selenium
        sel.open(response.url)
        sel.wait_for_page_to_load("30000")
        import time

        time.sleep(2.5)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 子洲县| 尖扎县| 抚顺县| 灵寿县| 青田县| 溧水县| 三台县| 塔河县| 瓮安县| 宁城县| 文山县| 山东省| 康乐县| 冷水江市| 松江区| 巴林右旗| 江永县| 米易县| 谷城县| 衡阳市| 襄垣县| 广宗县| 乡城县| 汝城县| 邳州市| 绥宁县| 榆社县| 逊克县| 昌都县| 浦北县| 和龙市| 临江市| 东莞市| 民权县| 灵山县| 泰宁县| 北辰区| 桂平市| 吉首市| 麻江县| 武义县|