Commit 2635603d authored by Zen's avatar Zen Committed by Francesco Poldi

Fix get User info by proxy (#298)

* Fix UnboundLocalError

UnboundLocalError: local variable 'soup' referenced before assignment

* Fix get User info by proxy

get User Request by SocksConnector
parent 2bb80a4f
...@@ -16,8 +16,8 @@ from .user import inf ...@@ -16,8 +16,8 @@ from .user import inf
#import logging #import logging
async def RequestUrl(config, init, headers = []):
#loggin.info("[<] " + str(datetime.now()) + ':: get+requestURL') def get_connector(config):
_connector = None _connector = None
if config.Proxy_host is not None: if config.Proxy_host is not None:
if config.Proxy_host.lower() == "tor": if config.Proxy_host.lower() == "tor":
...@@ -47,6 +47,13 @@ async def RequestUrl(config, init, headers = []): ...@@ -47,6 +47,13 @@ async def RequestUrl(config, init, headers = []):
print("Error: Please specify --proxy-host, --proxy-port, and --proxy-type") print("Error: Please specify --proxy-host, --proxy-port, and --proxy-type")
sys.exit(1) sys.exit(1)
return _connector
async def RequestUrl(config, init, headers = []):
#loggin.info("[<] " + str(datetime.now()) + ':: get+requestURL')
_connector = get_connector(config)
if config.Profile: if config.Profile:
if config.Profile_full: if config.Profile_full:
_url = await url.MobileProfile(config.Username, init) _url = await url.MobileProfile(config.Username, init)
...@@ -133,16 +140,16 @@ async def Tweet(url, config, conn): ...@@ -133,16 +140,16 @@ async def Tweet(url, config, conn):
async def User(url, config, conn, user_id = False): async def User(url, config, conn, user_id = False):
#loggin.info("[<] " + str(datetime.now()) + ':: get+User') #loggin.info("[<] " + str(datetime.now()) + ':: get+User')
_connector = get_connector(config)
try: try:
response = await Request(url) response = await Request(url, connector=_connector)
soup = BeautifulSoup(response, "html.parser") soup = BeautifulSoup(response, "html.parser")
await Users(soup, config, conn) await Users(soup, config, conn)
if user_id:
return int(inf(soup, "id"))
except Exception as e: except Exception as e:
print(str(e) + " [x] get.User") print(str(e) + " [x] get.User")
if user_id:
return int(inf(soup, "id"))
def Limit(Limit, count): def Limit(Limit, count):
#loggin.info("[<] " + str(datetime.now()) + ':: get+Limit') #loggin.info("[<] " + str(datetime.now()) + ':: get+Limit')
if Limit is not None and count >= int(Limit): if Limit is not None and count >= int(Limit):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment