123456789101112131415161718 |
- import requests
- from bs4 import BeautifulSoup
- s= requests.Session()
- r=s.get('http://localhost/moodle/login/index.php')
- soup = BeautifulSoup(r.text, 'html.parser')
- logintoken = soup.find('input', {"name": "logintoken"} )['value']
- login_data= {'logintoken':logintoken,'username':'dummy1' ,'password': 'Dummy@123'}
- s.post('http://localhost/moodle/login/index.php', login_data)
- url = 'http://localhost/moodle/pluginfile.php/37/mod_resource/content/1/silabo-de-lengua-i-1-728.jpg'
- r= s.get(url)
- with open('something.jpg', 'wb') as f:
- f.write(r.content)
- url='http://localhost/moodle/pluginfile.php/38/mod_resource/content/1/Greetings.pdf'
- r= s.get(url)
- with open('espanol.pdf', 'wb') as f:
- f.write(r.content)
-
- requests.Session().close()
|