# 抓取今日头条的新闻链接

from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait

option = webdriver.ChromeOptions()
# option.add_argument('headless')

driver = webdriver.Chrome(
    executable_path='H:/workspace/软件/chromedriver_win32/chromedriver',
    chrome_options=option
)

# 今日头条
url = 'https://www.toutiao.com'

driver.get(url)
print(driver.page_source)

timeout = 5
coin_links = WebDriverWait(driver, timeout).until(
    lambda d: d.find_elements_by_xpath('//div[@ga_event="article_title_click"]/a')
)

for item in coin_links:
    print(item.text)
    print(item.get_attribute('href'))
06820f711437f28463ab1281b0586b9fe613bd04
<mask token>

<mask token>
driver.get(url)
print(driver.page_source)
<mask token>
for item in coin_links:
    print(item.text)
    print(item.get_attribute('href'))

<mask token>
option = webdriver.ChromeOptions()
driver = webdriver.Chrome(executable_path=
    'H:/workspace/软件/chromedriver_win32/chromedriver', chrome_options=option)
url = 'https://www.toutiao.com'
driver.get(url)
print(driver.page_source)
timeout = 5
coin_links = WebDriverWait(driver, timeout).until(lambda d: d.
    find_elements_by_xpath('//div[@ga_event="article_title_click"]/a'))
for item in coin_links:
    print(item.text)
    print(item.get_attribute('href'))

from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
option = webdriver.ChromeOptions()
driver = webdriver.Chrome(executable_path=
    'H:/workspace/软件/chromedriver_win32/chromedriver', chrome_options=option)
url = 'https://www.toutiao.com'
driver.get(url)
print(driver.page_source)
timeout = 5
coin_links = WebDriverWait(driver, timeout).until(lambda d: d.
    find_elements_by_xpath('//div[@ga_event="article_title_click"]/a'))
for item in coin_links:
    print(item.text)
    print(item.get_attribute('href'))

# 抓取今日头条的新闻链接

from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait

option = webdriver.ChromeOptions()
# option.add_argument('headless')

driver = webdriver.Chrome(
    executable_path='H:/workspace/软件/chromedriver_win32/chromedriver',
    chrome_options=option
)

# 今日头条
url = 'https://www.toutiao.com'

driver.get(url)
print(driver.page_source)

timeout = 5
coin_links = WebDriverWait(driver, timeout).until(
    lambda d: d.find_elements_by_xpath('//div[@ga_event="article_title_click"]/a')
)

for item in coin_links:
    print(item.text)
    print(item.get_attribute('href'))