ダウンロードしたいすべてのimage_urlを出力するコードがあります。
次に
、出力に含まれている目的のimage_name = uni_nameを含むfolder_name = scrap_imagesのローカルフォルダーに保存します
。
response = requests.get('https://www.eduvision.edu.pk/admissions.php?
discipline_type=Social-Sciences&sub_level=7&city=&pageNo=2',headers=header)
soup = BeautifulSoup(response.content, 'html.parser')
data=soup.findAll('div',attrs={'class':'col-lg-12 col-xs-12'})[:-1]
for d in data:
uni_name,comma,city = (d.findAll('a')[1].text).partition(',')
print(uni_name)
admis_img = d.img['src']
if(d.img['src']=="images_post/nust.jpg"):
admis_img= "https://www.eduvision.edu.pk/"+d.img['src']
print(admis_img)
else:
print(admis_img)
Pythonを使用して画像をダウンロードする最も簡単な方法は、Requestsモジュールを使用することです。
あなたはそれについてもっと読むことができます、それはあなたがそれを始めるのを助けるでしょう、私はあなたのためにコードサンプルも添付しました。
クエリをよりよく理解するために、この回答を参照することもできます。
# importing the requests library
import requests
`# api-endpoint
URL = "http://maps.googleapis.com/maps/api/geocode/json"`
# location given here
location = "ImageKit"
# defining a params dict for the parameters to be sent to the API
PARAMS = {'address':location}
# sending get request and saving the response as response object
r = requests.get(url = URL, params = PARAMS)
# extracting data in json format
data = r.json()
# extracting latitude, longitude and formatted address
# of the first matching location
latitude = data['results'][0]['geometry']['location']['lat']
longitude = data['results'][0]['geometry']['location']['lng']
formatted_address = data['results'][0]['formatted_address']
# printing the output
print("Latitude:%s\nLongitude:%s\nFormatted Address:%s"
%(latitude, longitude,formatted_address))
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加