Need Help with Plugin and Xpath

Hello @all!



I’m a long time fan of Plex, now started playing with Plugins. But i need some help with Xpath (its completely new for me)



I’m trying to fetch 10 videoclips from this website www.werder.tv/de (Goal)

At the moment i’m able to get one picture…



element = HTML.ElementFromURL('http://www.werder.tv/de').xpath('//html/body/div[@id="pagewrapper"]/div[@id="content"]')<br />
     for item in element:<br />
    img = item.xpath(".//img")[0].get("src"))



But i want to get the Thumbs some level deeper... i spend many hours with no luck!
I need the content of every
item.

Could somebody give me a hint to solve this problem?
Thanks in advance

FTZ


<br />
<head><br />
</head><br />
<body><br />
<div id="_atssh" style="visibility: hidden; height: 1px; width: 1px; position: absolute; z-index: 100000;"><br />
</div><br />
<div id="pagewrapper"><br />
<a name="top"></a><br />
<div id="head"><br />
</div><br />
<div id="content" class="werdertv"><br />
<div id="box_topteaser" class="box_topteaser"><br />
</div><br />
<script type="text/javascript"><br />
</script><br />
<div id="tvplayer"> </div><br />
<div class="programmvorschau_head"><br />
</div><br />
<div class="programmvorschau" style="overflow: hidden; padding: 0px; width: 340px;"><br />
</div><br />
<div class="videolist"><br />
<div style="display: inline-block;"><br />
<div id="givenTag" style="display: none;"></div><br />
<div class="filterBack"><br />
</div><br />
<div class="sorting_paging"><br />
</div><br />
<div id="VideoResults"><br />
<div class="Elem Elem_other"><br />
</div><br />
<div class="Elem Elem_other"><br />
</div><br />
<div class="Elem Elem_other"><br />
</div><br />
<div class="Elem Elem_other"><br />
</div><br />
<div class="Elem Elem_other"><br />
</div><br />
<div class="Elem Elem_other"><br />
</div><br />
<div class="Elem Elem_other"><br />
</div><br />
<div class="Elem Elem_other"><br />
</div><br />
<div class="Elem Elem_other"><br />
</div><br />
<div class="Elem Elem_other"><br />
</div><br />
<div class="clear"></div><br />
</div><br />
</div><br />
</div><br />
<div class="videolist sportline"><br />
<div class="SportlineHead regular"><br />
</div><br />
<div id="VideoResultsSportline" class="regular"><br />
</div><br />
</div><br />
</div><br />


Within your existing loop this should give you a list of those items that you can then loop over (i.e. two nested loops) if that’s what you are after



<br />
innerItems = item.xpath(".//div[@id='VideoResults']/div")<br />




hope that helps
Jonny

Hello FTZ!

The data you want to retrieve from that website is loaded after the webpage is loaded. The xpath works in a browser, but it will certainly not work in your plugin code. The data is retrieved by doing an XMLHttpRequest. The url it hits is


http://www.werder.tv/service.php?cc=de&service=video&method=getByTags&args[tags]=&args[limit]=10&args[offset]=10&args[sort]=SDD&args[quality]=&args[nr]=&args[type]=free,pay

and this returns all the information formatted as JSON.

Hope this helps!

Hello Jonny, Hello Sander1!



Thanks a lot for your help!!! I just learned a lot from both hints :slight_smile:

Sending an xmlHttpRequest works perfect! Thx Sander!!! I got now all the menus working… where did you found the “link” for the request?

But i just realized that i have to care about authentication … and making a site configuration seems absolutely impossible at the moment to me :o

I have to learn a lot more to get this plugin finished …



Anyway again thanks a lot!



FTZ

Hello FTZ!


To get information about all the http request done by the website, I use this [HttpFox](https://addons.mozilla.org/en-US/firefox/addon/httpfox/) addon for Firefox.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.