I am trying to scrape a very simple web page with the help of Scrapy and it's xpath selectors but for some reason the selectors I have do not work in Scrapy but they do work in other xpath utilities
I am trying to parse this snippet of html:
<select id="chapterMenu" name="chapterMenu">
<option value="/111-3640-1/20th-century-boys/chapter-1.html" selected="selected">Chapter 1: Friend</option>
<option value="/111-3641-1/20th-century-boys/chapter-2.html">Chapter 2: Karaoke</option>
<option value="/111-3642-1/20th-century-boys/chapter-3.html">Chapter 3: The Boy Who Bought a Guitar</option>
<option value="/111-3643-1/20th-century-boys/chapter-4.html">Chapter 4: Snot Towel</option>
<option value="/111-3644-1/20th-century-boys/chapter-5.html">Chapter 5: Night of the Science Room</option>
</select>
Scrapy parse_item code:
def parse_item(self, response):
itemLoader = XPathItemLoader(item=MangaItem(), response=response)
itemLoader.add_xpath('chapter', '//select[@id="chapterMenu"]/option[@selected="selected"]/text()')
return itemLoader.load_item()
Scrapy does not extract any text from this but if I get the same xpath and html snippet and run it here it works just fine.
if I use this xpath:
//select[@id="chapterMenu"]
I get the correct element but when I try to access the options inside it does not get anything
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…