Python 3.4です。
Javascriptを使ったウェブページのスクレイピングをしようとしているのですが、ページ途中から抽出ができなくなりました。
サンプルURL
https://www.crd.york.ac.uk/prospero/display_record.php?RecordID=26939
Stage of review
の次の<p></p>を抽出しようとしています。
Countryまでは抽出できるのですが、なぜかStage of review以下の全てが読めず、空白のみが返ってきます。
import lxml.html from selenium import webdriver url="https://www.crd.york.ac.uk/prospero/display_record.php?RecordID=26939" driver = webdriver.PhantomJS(executable_path='C:/Users/XX/phantomjs-2.1.1-windows/bin/phantomjs.exe') driver.get(url) root = lxml.html.fromstring(driver.page_source) country = root.xpath('string(//h1[contains(text(),"Country")]/following-sibling::p[1])') #ここから上手く動かない stage= root.xpath('string(//h1[contains(text(),"Stage of review")][1]/following-sibling::p[1])') driver.quit()
回答1件
あなたの回答
tips
プレビュー