Javascript-scrpy Crawlspider automatically crawl to the webpage problem

Source: Internet
Author: User
# My code is as follows, the problem is in the code comment
From SCRAPY.CONTRIB.LINKEXTRACTORS.SGML import Sgmllinkextractor as SLE #用于定义需要提取的链接
Class Newsspider (Crawlspider):

name = "demo2"allowed_domains = ["360.cn"]# start_urls=["http://bobao.360.cn/activity/index&page=2"]#这个连接测试成功# rules = [ Rule(sle(allow=r'/vul/index?type=all&page=\d{1,3}'), follow=True,callback='parse_item1') ]#*这个测试不成功原因好像*#allow=r'/vul/index?type=all&page=\d{1,3} 这个里面/vul/index?这个?有影响,请教如何修改rules = [ Rule(sle(allow=r'/activity/index&page=\d{1,3}'), follow=True,callback='parse_item1') ]#这个连接测试成功

/activity/index&page=

def parse_item1(self, response):    print u'这是谁?????????????????????'    

Reply content:

# My code is as follows, the problem is in the code comment
From SCRAPY.CONTRIB.LINKEXTRACTORS.SGML import Sgmllinkextractor as SLE #用于定义需要提取的链接
Class Newsspider (Crawlspider):

name = "demo2"allowed_domains = ["360.cn"]# start_urls=["http://bobao.360.cn/activity/index&page=2"]#这个连接测试成功# rules = [ Rule(sle(allow=r'/vul/index?type=all&page=\d{1,3}'), follow=True,callback='parse_item1') ]#*这个测试不成功原因好像*#allow=r'/vul/index?type=all&page=\d{1,3} 这个里面/vul/index?这个?有影响,请教如何修改rules = [ Rule(sle(allow=r'/activity/index&page=\d{1,3}'), follow=True,callback='parse_item1') ]#这个连接测试成功

/activity/index&page=

def parse_item1(self, response):    print u'这是谁?????????????????????'    

It is important to note that the conversion of the number is to be escaped by copying the number.

The link in the webpage is this: #/rwxwsblog/default.html?page=3 "
It should be written like this: Rule (SLE (allow= ("/rwxwsblog/default.html\?page=\d{1,}")), the conversion of #此处要注意 number, and copying it requires escaping the number.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.