View Single Post
Old 07-22-2020, 01:43 AM   #469
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by kcar181 View Post
Hi guys Im trying to figure out a custom webpage

http://www.worldswithoutend.com

I figured some of it out but ive never used xpath before. Titles are fine but all the authors are adding combined. "Bob & Sue & Lee" instead of:
Bob
Sue
Lee



//*[@id="reportlist"]
.//p[@class="title"]/a/text()
.//p[@class="author"]/a/text()

This is what im using for page:
https://www.worldswithoutend.com/lists_banned_sff.asp
The problem is the XPath for the row. What you have identifies the full list. What you need is to identify each book in the list. If you look at the source for the list, each book looks like:

Code:
<div class="awardslisting">
  <div class="gallery">
    
	<a href="novel.asp?id=698" class="trophy trophy2" onMouseOver="return overlib('Total Award Nominations: 2', WIDTH, '200', RIGHT)" onMouseOut="nd();"></a>
	
	<a href="novel.asp?id=698" class="trophyx trophyx1" onMouseOver="return overlib('Total Book List Inclusions: 1', WIDTH, '200', RIGHT)" onMouseOut="nd();"></a>
	
    <a href="novel.asp?ID=698"><img src="covers_md/pp_theamber.jpg" border="0" alt="The Amber Spyglass" /><!-- If winner then <span class="gold"></span> else if nom then <span class="silver"></span> end if --></a>
    
  </div>
  <p class="title"><a href="novel.asp?ID=698">THE AMBER SPYGLASS</a></p>
  <p class="author"><a href="author.asp?ID=694">Philip Pullman</a></p>
</div>
Each book is within the div with class "awardslisting". So, the following should work:
Code:
//div[@class="awardslisting"]
Your XPaths for the title and author are correct.
davidfor is offline   Reply With Quote