Anyone want to make a small tut please ?
Like how to dim them, how the posting works, and the between methods, just like an Httpwrapper in .NET Programming
Results 1 to 8 of 8
- 11 Jun. 2012 10:30am #1
How to Use HTTPwrappers in Python ?
- 11 Jun. 2012 10:40am #2
The methodology is the exact same, the syntax changes slightly. Look in to urllib/2. Or, just look at some source code examples: http://forum.logicalgamers.com/sourc...er-source.html
- 11 Jun. 2012 10:49am #3
MAtt gave me that site whre he puts all of the LG projects, had the HTTPwrapper.py and all, but the syntax is the only thing that kills me.
- 12 Jun. 2012 01:35am #4
What HTTP Wrapper are you using? If you're using this one:
PHP Code:import urllib
import urllib2
import cookielib
class HTTPWrapper:
def __init__(self, KeepCookies=True):
if(KeepCookies):
self.cj = cookielib.CookieJar()
self.HTTP = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cj))
else:
self.HTTP = urllib2.build_opener()
def Req(self, URL, data={}):
return self.HTTP.open(URL,urllib.urlencode(data)).read()
PHP Code:import HTTPWrapper
Wrapper = HTTPWrapper.HTTPWrapper()
HTML = Wrapper.Req("http://www.google.com/")
PHP Code:import HTTPWrapper
Wrapper = HTTPWrapper.HTTPWrapper()
Data = {"item1": "value", "item2": "value"}
HTML = Wrapper.Req("http://www.google.com/", Data)
- 12 Jun. 2012 02:58pm #5
- 12 Jun. 2012 06:03pm #6
Most of what you need is readily available in Python's standard library. There's BeautifulSoup, which is an HTML/markup parser. That's the only third-party library I've ever had to use really.
- 12 Jun. 2012 07:47pm #7
- 29 Jul. 2012 05:04pm #8
A library and wrapper aren't exactly two synonymous things (though they're both wrappers in the sense that they "wrap" the HTTP protocol functionality into a condensed, abstract form). The requests library is a lot more comprehensive than a standard wrapper built for HTTP tasks (which isn't necessarily a bad thing unless you're concerned with brevity of code), and a lot less user-defined and arbitrary.
For instance, if you made a library on top of the requests library, that would be a "wrapper" for it. And there are potential advantages to doing that (e.g. including what you need, omitting what you don't need, and adding other conveniences homogeneous libraries like requests typically don't feature).
As for the parsing library, BeautifulSoup is capable of all that and possibly even more. Usually people use methods like string between as opposed to extensive libraries like lxml and BeautifulSoup because in a lot of use cases they only require so much.Last edited by The Unintelligible; 29 Jul. 2012 at 05:13pm.