Hi all,
My second post here. Quite new to the whole Python language, as well as XPath.
I was wondering, how can I distinguish the xpath of two
's which are using the exact same div class name? The page I'm scraping is:
http://www.ddizi.org/yeni.eklenenler
I'm trying to retrieve all the data in the table on the left called 'Yeni Diziler' and then later will retrieve all the data in the table below called 'Eski Diziler'.
I have:
for show in HTML.ElementFromURL(URL).xpath('//div[@class="sol-blok"]/div/div/div/div'):
title = show.xpath('./ul/li/a//text()')[0]
Trouble is, the whole left table is in a div called '<div class="sol-blok">'. Anyone have any idea?
Cheers,
Ozzie
Hi!
The only piece of information that is really different in those lists is the title. You can use this to make a distinction between the lists you want. For example, you can extract the first list with programmes with this xpath query:
//div[@class="blok-ust"]//a[text()="Tv Showlar"]/../..//li/a/text()
The second list can be found with this query (by just changing the title in the query):
//div[@class="blok-ust"]//a[text()="Yabancı Diziler"]/../..//li/a/text()
Hello,
Thanks for the reply mate, slowly getting my head around all this new stuff.
How would it work within a for loop though?
for show in HTML.ElementFromURL(URL).xpath('//div[@class="blok-ust"]'):
title = show.xpath('//a[text()="Yerli Diziler"]/../..//li/a/text()')
for show in HTML.ElementFromURL(URL).xpath('//div[@class="blok-ust"]//a[text()="Tv Showlar"]/../..//li/a'):
title = show.xpath('./text()')[0]
url = show.xpath('./@href')[0]
Thank you, much appreciated mate :)