Esempio n. 1
0
    def __init__(self, root):
        self.myls = lswww.lswww(root)
        self.root = self.myls.root
        self.server = urlparse.urlparse(self.root)[1]
        self.myls.verbosity(1)
        socket.setdefaulttimeout(self.timeout)

        # HttpLib2 vars
        proxy = None

        if self.proxy != "":
            (proxy_type, proxy_usr, proxy_pwd, proxy_host, proxy_port, path, query, fragment) = httplib2.parse_proxy(
                self.proxy
            )
            proxy = httplib2.ProxyInfo(proxy_type, proxy_host, proxy_port, proxy_user=proxy_usr, proxy_pass=proxy_pwd)

        self.cookiejar = libcookie.libcookie(self.server)

        self.h = httplib2.Http(cache=None, timeout=self.timeout, proxy_info=proxy)
        self.h.follow_redirects = False

        if self.auth_basic != []:
            self.h.add_credentials(self.auth_basic[0], self.auth_basic[1])
Esempio n. 2
0
  p.feed(htmlSource)
except HTMLParser.HTMLParseError,err:
  if tidyhere==1:
    options = dict(output_xhtml=1, add_xml_decl=1, indent=1, tidy_mark=0)
    htmlSource=str(tidy.parseString(htmlSource,**options))
    try:
      p.reset()
      p.feed(htmlSource)
    except HTMLParser.HTMLParseError,err:
      pass

if len(p.forms)==0:
  print "No forms found in this page !"
  sys.exit(1)

myls=lswww.lswww(url,box=0,timeToQuit=0)
i=0
nchoice=0
if len(p.forms)>1:
  print "Choose the form you want to use :"
  for form in p.forms:
    print
    print "%d) %s" % (i,myls.correctlink(form[0],current,currentdir,proto))
    for field,value in form[1].items():
      print "\t"+field+" ("+value+")"
    i=i+1
  ok=False
  while ok==False:
    choice=raw_input("Enter a number : ")
    if choice.isdigit():
      nchoice=int(choice)
Esempio n. 3
0
except HTMLParser.HTMLParseError, err:
    htmlSource = bs.prettify()
    try:
        p.reset()
        p.feed(htmlSource)
    except HTMLParser.HTMLParseError, err:
        p = lswww.linkParser2(url)
        p.feed(htmlSource)

jc.addcookies(r.cookies)

if len(p.forms) == 0:
    print(_("No forms found in this page !"))
    sys.exit(1)

myls = lswww.lswww(url)
i = 0
nchoice = 0
if len(p.forms) > 1:
    print(_("Choose the form you want to use :"))
    for form in p.forms:
        print('')
        print(u"{0}) {1}".format(i, myls.correctlink(form[0], current, currentdir, proto)))
        for field, value in form[1].items():
            print(u"\t{0} ({1})".format(field, value))
        i += 1
    ok = False
    while not ok:
        choice = raw_input(_("Enter a number : "))
        if choice.isdigit():
            nchoice = int(choice)
Esempio n. 4
0
  p.feed(htmlSource)
except HTMLParser.HTMLParseError, err:
  htmlSource = BeautifulSoup.BeautifulSoup(htmlSource).prettify()
  try:
    p.reset()
    p.feed(htmlSource)
  except HTMLParser.HTMLParseError, err:
    pass

lc.add(fd, htmlSource)

if len(p.forms) == 0:
  print _("No forms found in this page !")
  sys.exit(1)

myls = lswww.lswww(url)
i = 0
nchoice = 0
if len(p.forms) > 1:
  print _("Choose the form you want to use :")
  for form in p.forms:
    print
    print "%d) %s" % (i, myls.correctlink(form[0], current, currentdir, proto))
    for field, value in form[1].items():
      print "\t" + field + " (" + value + ")"
    i += 1
  ok = False
  while ok == False:
    choice = raw_input(_("Enter a number : "))
    if choice.isdigit():
      nchoice = int(choice)