Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menú#!/usr/bin/env python3
import urllib.request, urllib.parse
class CrawlerGeneral ():
def __init__(self):
self.headers = [("User-Agent", "Mozilla/5.0 (Windows; en-US; XP) Gecko/20101028 Firefox/3.5.15"),
("Accept", "*/*"), ("Accept-Language":"en-us,en;q=0.5"),
("Accept-Encodingg", "gzip,deflate"), ("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7")]
self.opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor())
self.referer = ''
def open(self, url, params = None):
self.opener.addheaders = self.headers + [('Referer', self.referer)]
self.referer = url
if not params is None:
params = bytes(urllib.parse.urlencode(params), 'utf-8')
resp = self.opener.open(url, params)
return resp.read().decode('utf-8')
from crawlergeneral import CrawlerGeneral
from re import findall
cg = CrawlerGeneral()
data = cg.open('http://foros.solocodigo.com/ucp.php?mode=login')
sid = findall('type="hidden" name="sid" value="([^"]+)"', data)[0]
data = cg.open('http://foros.solocodigo.com/ucp.php?mode=login', {'username=':'Invisible','password':'password', 'sid':sid, 'redirect': 'index.php', 'login':'Identificarse'})
print(cg.open('http://foros.solocodigo.com/'))
import http.client, urllib.parse
from http import cookies
from re import findall
class CrawlerGeneral ():
def __init__(self):
self.logininfo = []
self.baseheaders = {"User-Agent":"Mozilla/5.0 (Windows; en-US; XP) Gecko/20101028 Firefox/3.5.15",
"Accept": "*/*", "Accept-Language":"en-us,en;q=0.5",
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7"}
self.cookies = cookies.SimpleCookie()
self.referer = ''
def _act(self, url, method, params={}):
headers = self.baseheaders.copy()
headers['Referer'] = self.referer
headers['Cookie'] = self.cookies.output(header='', sep=';')
self.referer = url
if(url[:7] == 'htt'+'p://'):
url = url[7:]
safe = False
elif (url[:8] == 'htt'+'ps://'):
url = url[8:]
safe = True
else:
self.error("I don't like the protocol, I don't know how to handle this.\n" + url)
(baseurl, extendedurl) = url.split('/', 1)
extendedurl = '/' + extendedurl
params = urllib.parse.urlencode(params)
conn = http.client.HTTPConnection(baseurl) if not safe else http.client.HTTPSConnection(baseurl)
conn.request(method, extendedurl, params, headers)
resp = conn.getresponse()
return self._processResponse(resp)
def _processResponse(self, resp):
data = resp.read()
headers = resp.getheaders()
data = bytes.decode(data)
for (k, v) in headers:
if k == 'Set-Cookie':
self.cookies.load(v)
return (headers, data)
def post(self, url, params):
realparams = urllib.parse.urlencode(params)
return self._act(url, 'POST', params)
def get(self, url):
return self._act(url, 'GET')
from crawlergeneral import CrawlerGeneral
from re import findall
cg = CrawlerGeneral()
(headers, data) = cg.get('htt'+'p://foros.solocodigo.com/ucp.php?mode=login')
sid = findall('type="hidden" name=%2526quot%253Bsid%2526quot%253B value="([^"]+)"', data)[0]
(headers, data) = cg.post('htt'+'p://foros.solocodigo.com/ucp.php?mode=login', {'username' : 'Invisible', 'password': 'password', 'sid':sid, 'redirect': 'index.php', 'login':'Identificarse'})
print(data)
CitarNo se puede establecer una conexión de datos fiable con el servidor.
Es posible que se trate de un problema temporal o que no se proporcione la tarjeta SIM para servicios de datos. Si el problema persiste, llama al servicio de atención al cliente.