-
Notifications
You must be signed in to change notification settings - Fork 8
/
Pictures.py
45 lines (38 loc) · 1022 Bytes
/
Pictures.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
import urllib2
import requests
import pandas as pd
import shutil
df = pd.read_csv("PlayerNames.csv")
print("Read complete")
url = "https://www.fifaindex.com"
proxies = {
'http': 'http://10.4.22.5:3128',
'https': 'https://10.4.22.5:3128',
}
for i in range(1100):
print(i)
url_temp = url+df['url'][i]
while(True):
print("Getting page for "+df['Name'][i])
try:
page = requests.get(url_temp,proxies=proxies)
except requests.exceptions.RequestException as e: # This is the correct syntax
print(e)
continue
break
html = page.content
soup = BeautifulSoup(html,'lxml')
Nat = soup.find('img')
print(Nat['src'])
while(True):
try:
response = requests.get(url+Nat['src'], stream=True,proxies=proxies)
except requests.exceptions.RequestException as e: # This is the correct syntax
print(e)
continue
break
with open('Pictures/'+df['Name'][i]+'.png', 'wb') as out_file:
shutil.copyfileobj(response.raw, out_file)
del response