# Need Help with Plugin and Xpath

**URL:** <https://forums.plex.tv/t/need-help-with-plugin-and-xpath/10715>\
**Category:** Dev/API Corner\
**Tags:** plugin-dev\
**Created:** [August 26, 2011, 11:22pm UTC](https://forums.plex.tv/t/need-help-with-plugin-and-xpath/10715 "2011-08-26T23:22:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![FTZ07](https://avatars.discourse-cdn.com/v4/letter/f/e79b87/32.png) [@FTZ07](https://forums.plex.tv/u/FTZ07)\
**Post date:** [August 26, 2011, 11:22pm UTC](https://forums.plex.tv/t/need-help-with-plugin-and-xpath/10715/1 "2011-08-26T23:22:11Z")

</div>

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](http://www.werder.tv/de) (Goal)  
  
At the moment i’m able to get one picture…

```auto

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  
  

```auto

<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 />

```

---

<div class="post-metadata">

**Author:** ![jwray](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/jwray/32/99832_2.png) [@jwray](https://forums.plex.tv/u/jwray)\
**Post date:** [August 27, 2011, 5:22pm UTC](https://forums.plex.tv/t/need-help-with-plugin-and-xpath/10715/2 "2011-08-27T17:22:48Z")

</div>

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

```auto

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

```

  
  
hope that helps  
Jonny

---

<div class="post-metadata">

**Author:** ![sander1](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@sander1](https://forums.plex.tv/u/sander1)\
**Post date:** [August 28, 2011, 1:13am UTC](https://forums.plex.tv/t/need-help-with-plugin-and-xpath/10715/3 "2011-08-28T01:13:53Z")

</div>

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

```auto

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!

---

<div class="post-metadata">

**Author:** ![FTZ07](https://avatars.discourse-cdn.com/v4/letter/f/e79b87/32.png) [@FTZ07](https://forums.plex.tv/u/FTZ07)\
**Post date:** [August 28, 2011, 10:27pm UTC](https://forums.plex.tv/t/need-help-with-plugin-and-xpath/10715/4 "2011-08-28T22:27:51Z")

</div>

Hello Jonny, Hello Sander1!  
  
  
  
Thanks a lot for your help!!! I just learned a lot from both hints 🙂  
  
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

---

<div class="post-metadata">

**Author:** ![sander1](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@sander1](https://forums.plex.tv/u/sander1)\
**Post date:** [August 30, 2011, 4:16pm UTC](https://forums.plex.tv/t/need-help-with-plugin-and-xpath/10715/5 "2011-08-30T16:16:51Z")

</div>

Hello FTZ!

> [@](#):
>
> where did you found the "link" for the request?

  
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.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [December 20, 2019, 9:22pm UTC](https://forums.plex.tv/t/need-help-with-plugin-and-xpath/10715/6 "2019-12-20T21:22:07Z")

</div>

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