Plex networking on 0.9.5

HTML.Request plz help
Seems like something changed in HTTP.Request, my plugin suddenly stops working.


res = HTTP.Request(url, headers = {'User-agent': UserAgent})



[list=1]

[*]How to watch raw output?
[*]**len(res)** should show size of webpage in bytes? In my case **len(res)** returns equal results (4168, too small for webpage) for all requests =)
[*]Should I use **HTML.ElementFromString(res)** or **HTML.ElementFromString(res.content)** ?
[/list]

Help me plz.

Hey!




The line with HTTP.Request should look like this:

res = HTTP.Request(url, headers = {'User-agent': UserAgent}).content


with *.content* at the end.

*len(res)* returning 4168 could be right, because *len()* returns the length of a string, not the number of bytes.

HTML.ElementFromString is only needed if you want to parse the HTML document as a HTML DOM, for use with Xpath for example.


Nope, works fine without .content =)



I was exactly need to parse html and use with path, thanks =)

BTW in my case I should use headers = {'User-agent': UserAgent, **'Accept': 'text/html'**}. Else it drops all html tags content =(

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