Skip to content

Commit d618713

Browse files
committed
parsed needed css via pure beautifulsoap
1 parent ad64023 commit d618713

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

project/http/requests/proxy/requestProxy.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,11 @@ def samair_url_parser(self, web_url, speed_in_KBs=100.0):
133133
curr_proxy_list = []
134134
content = requests.get(web_url).content
135135
soup = BeautifulSoup(content, "html.parser")
136-
# css provides the prot number so we reverse it
137-
style = "http://www.samair.ru" + str(soup.find_all('link', attrs={'type':'text/css'})).split('\n')[1].split("\"")[1]
136+
# css provides the port number so we reverse it
137+
for href in soup.findAll('link'):
138+
if '/styles/' in href.get('href'):
139+
style = "http://www.samair.ru" + href.get('href')
140+
break
138141
css = requests.get(style).content.split('\n')
139142
css.pop()
140143
ports = {}
@@ -164,6 +167,7 @@ def generate_proxied_request(self, url, params={}, req_timeout=30):
164167
request = None
165168
try:
166169
rand_proxy = random.choice(self.proxy_list)
170+
print "Next proxy: " + str(rand_proxy)
167171
request = requests.get(test_url, proxies={"http": rand_proxy},
168172
headers=req_headers, timeout=req_timeout)
169173
except ConnectionError:

0 commit comments

Comments
 (0)