Created
November 23, 2016 08:21
-
-
Save lionelyoung/dd8a3eae9e0adcf6ba4a82e5c1c5c46c to your computer and use it in GitHub Desktop.
dryscrape user agent demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sess = dryscrape.Session() | |
sess.set_header("User-Agent", "Mozilla/5.0 (Windows NT 5.1; rv:41.0) Gecko/20100101 Firefox/41.0") | |
sess.visit("https://carelink.minimed.eu/patient/") | |
username = sess.at_xpath('//*[@id="j_username"]') | |
username.set("your_username") | |
password = sess.at_xpath('//*[@id="j_password"]') | |
password.set("your_password") | |
# submit form | |
username.form().submit() | |
sess.visit("https://carelink.minimed.eu/patient/main/reports.do") | |
reportlink = sess.at_xpath('//*[@id="lastLI"]/a') | |
reportlink.click() | |
sd = sess.at_xpath('//*[@id="startDate11"]') | |
sd.set("11/09/2015") | |
ed = sess.at_xpath('//*[@id="endDate11"]') | |
ed.set("18/09/2015") | |
gbutton = sess.at_xpath('//*[@id="reportPicker11"]//*[@id="reportNav_button"]') | |
gbutton.click() | |
import codecs | |
target = codecs.open("/tmp/test.txt", 'w', encoding='utf8') | |
target.write(sess.body()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment