我未能從網站中提取第一列“名稱”。有沒有人可以幫忙?網址為:https ://www.dianashippinginc.com/the-fleet/
'''
chromedriver_location = ""
driver = webdriver.Chrome(chromedriver_location)
driver.get('https://www.dianashippinginc.com/fleet-employment-table/')
cookie_address = '//*[@id="ccc-notify-accept"]/span'
name_address = '/html/body/div[3]/div/div/div[2]/table/tbody/tr[3]/td[2]/span'
driver.find_element_by_xpath(cookie_address).click()
driver.find_element_by_xpath(name_address)
'''
uj5u.com熱心網友回復:
import scrapy
class MySpider(scrapy.Spider):
name = 'myspider'
start_urls = [r'https://www.dianashippinginc.com/the-fleet/']
def parse(self, response):
names = response.xpath('//div[@]/text()').getall()
# Process the names list to be as you want (remove tab characters, ranking numbers etc.)
yield names
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/424684.html
