python使用scrapy解析js示例
from selenium import selenium
class MySpider(CrawlSpider):
name = 'cnbeta'
allowed_domains = ['cnbeta.com']
start_urls = ['https://www.jb51.net']
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", "https://www.jb51.net")
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)
相关文章
python filecmp.dircmp实现递归比对两个目录的方法
这篇文章主要介绍了python filecmp.dircmp实现递归比对两个目录的方法,本文通过实例代码给大家介绍的非常详细,大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下2020-05-05关于 Python opencv 使用中的 ValueError: too many values to unpack
这篇文章主要介绍了关于 Python opencv 使用中的 ValueError: too many values to unpack,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧2019-06-06浅谈Python实现opencv之图片色素的数值运算和逻辑运算
今天带大家来学习的是关于Python的相关知识,文章围绕着图片色素的数值运算和逻辑运算展开,文中有非常详细的的介绍及代码示例,需要的朋友可以参考下2021-06-06python使用paramiko模块通过ssh2协议对交换机进行配置的方法
今天小编就为大家分享一篇python使用paramiko模块通过ssh2协议对交换机进行配置的方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2019-07-07
最新评论