여러 페이지가있는 웹 사이트를 스크랩 (scrape)하려고합니다. 이러한 페이지는 URL을 변경하지 않고 동적으로로드됩니다. 그래서 셀레늄을 사용하여 화면을 긁어냅니다. 그러나 나는이 간단한 프로그램에 대한 예외를 얻고있다.셀레늄 (파이썬 웹 크롤러 포함)
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: u'Unable to locate element: {"method":"link text","selector":"2"}' ; Stacktrace: Method FirefoxDriver.prototype.findElementInternal_ threw an error in file:///tmp/tmpMJeeTr/extensions/[email protected]/components/driver_component.js
가 주어진 URL 또는 파이어 폭스 브라우저의 문제 그 것이다 다음과 같이
import re
from contextlib import closing
from selenium.webdriver import Firefox
url="http://www.samsung.com/in/consumer/mobile-phone/mobile-phone/smartphone/"
with closing(Firefox()) as browser:
n = 2
link = browser.find_element_by_link_text(str(n))
link.click()
#web_page=browser.page_source
#print type(web_page)
오류입니다. 누군가 나를 도왔다면 큰 도움이 될 것입니다.
답장을 보내 주셔서 감사합니다. – Dhatri
@vindhya 전혀 문제 없습니다. 행운을 빈다. – RocketDonkey