首页 » Python » python定向爬虫:scrapy抓取百度m端竞价的标题

python定向爬虫:scrapy抓取百度m端竞价的标题

 
#coding:utf-8
import scrapy
import re
query = "手表回收"
class Dmozspider(scrapy.Spider):
    name = "seo"
    start_urls = ['http://www.baidu.com/s?wd=%s' % query]
    def parse(self, response):
        html=response.xpath("//*[@class='ec_ad_results']/*[@data-rank]").extract()
        for i in range(len(html)):
            print i,html[i],"\n\n\n\n\n"
        for html_list in html:
            for title in re.findall(r'(.*?)',html_list,re.S):
                print title

原文链接:python定向爬虫:scrapy抓取百度m端竞价的标题,转载请注明来源!

0