python download from mediafire with scraping

Solutions on MaxInterview for python download from mediafire with scraping by the best coders in the world

showing results for - "python download from mediafire with scraping"
Quinlan
03 Jan 2021
1import requests
2from bs4 import BeautifulSoup
3
4headers = {
5    'Access-Control-Allow-Origin': '*',
6    'Access-Control-Allow-Methods': 'GET',
7    'Access-Control-Allow-Headers': 'Content-Type',
8    'Access-Control-Max-Age': '3600',
9    'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0'
10    }
11MediaUrl = 'http://www.mediafire.com/file/nbl3q4tx8l4tyto/Python_in_Arabic.txt/file'
12
13url = MediaUrl
14req = requests.get(url, headers)
15soup = BeautifulSoup(req.content, 'html.parser')
16
17url = soup.find("a", class_="popsok").get('href')
18r = requests.get(url)
19
20print ("File Name : " + soup.find("div", class_="filename").get_text())
21print (soup.find("ul", class_="details").get_text())
22
23with open(soup.find("div", class_="filename").get_text(), 'wb') as f:
24    f.write(r.content)
25    print('Done ...')
26