Я хочу ввести несколько ссылок и удалить их данные, но я не знаю, как кодировать ..
import scrapy
from selenium import webdriver
from scrapy.selector import Selector
import time
from nhl.items import NHLItem
class NHL_Spider(scrapy.Spider):
name='NHL'
allowed_domains=["nhl.com"]
start_urls=["https://www.nhl.com/scores/2019-02-17"]
def __init__(self):
scrapy.Spider.__init__(self)
self.browser=webdriver.Chrome("/users/박정균/chromedriver")
def parse(self,response):
self.browser.get(response.url)
self.browser.find_element_by_xpath('//*[@id="2018020904"]').click()
self.browser.find_element_by_xpath('//*[@id="content-wrap"]/div/div[2]/div/section/div[2]/div/section/div/ul/li[2]/section/ul/li[3]/a').click()
source=self.browser.page_source
html=self.browser.find_element_by_xpath('//*').get_attribute('outerHTML')
selector=Selector(text=html)
rows = selector.xpath('//*[@class="statistics__season-stats"]/table/tbody/tr')
for row in rows:
item=NHLItem()
item["Team"]=row.xpath('.//*[@class="media-heading small"]/text()')[0].extract()
item["Shots"]=row.xpath('./td[2]/text()')[0].extract()
item["FO"]=row.xpath('./td[3]/text()')[0].extract()
item["PP"]=row.xpath('./td[4]/text()')[0].extract()
yield item
Это данные одного матча.Я хочу увеличить число xpath('//*[@id="201802090{here}"]')
и xpath('//*[@id="content-wrap"]/div/div[2]/div/section/div[2]/div/section/div/ul/li[{here}]/section/ul/li[3]/a')
(здесь спот) одновременно из-за следующего матча.Просто, 2018020904,2018020905,2018020906
и li[2],li[3],li[4]
в парах.