I am web crwaling but I keep getting troubles...
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element
there is a error in
click = '//*[@id="pagerTagAnchor' + str(j) + '"]'
driver.find_element_by_xpath(click).click()
what should i do?
import requests
from bs4 import BeautifulSoup
from selenium import webdriver
f = open('movie.txt', 'w', encoding='utf-8')
options = webdriver.ChromeOptions()
options.add_argument('headless')
options.add_argument('window-size=1920x1080')
options.add_argument("disable-gpu")
driver = webdriver.Chrome('C:/Users/Administrator/Downloads/chromedriver', chrome_options=options)
for i in range(1, 101):
for j in range(1, 11):
driver.get('https://movie.naver.com/movie/bi/mi/point.nhn?code=167638')
driver.implicitly_wait(20)
click = '//*[@id="pagerTagAnchor' + str(j) + '"]'
driver.find_element_by_xpath(click).click()
response = requests.get(str(driver.current_url))
html = driver.page_source
soup = BeautifulSoup(html, 'html.parser')
notices1 = soup.select(
'body > div > div > div.score_result > ul > li:nth-of-type(' + str(j) + ') > div.score_reple > p')
for n in notices1:
a = n.text.strip()
a = str(a).replace(",", "")
f.write(str(a) + ',')
f.close()
this is the full chord.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…