主程序代码:
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 import scrapy 2 from selenium import webdriver 3 4 class SelenuimtestSpider(scrapy.Spider): 5 name = 'selenuimTest' 6 # allowed_domains = ['www.xxx.com'] 7 start_urls = ['http://war.163.com/'] 8 9 def __init__(self): 10 #本地谷歌浏览器的驱动存放地址 11 self.bro = webdriver.Chrome(r'D:\爬虫相关\资料\驱动程序\chromedriver_win32\chromedriver.exe') 12 def parse(self, response): 13 print(response.xpath('/html/body/div[1]/div[3]/div[4]/div[1]/div/div/ul/li/div/div[3]/div[1]/h3/a/text()').extract_first()) 14 15 16 def closed(self,spider): 17 self.bro.quit()