Skip to content

Instantly share code, notes, and snippets.

@lionelyoung
Created November 23, 2016 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lionelyoung/dd8a3eae9e0adcf6ba4a82e5c1c5c46c to your computer and use it in GitHub Desktop.
Save lionelyoung/dd8a3eae9e0adcf6ba4a82e5c1c5c46c to your computer and use it in GitHub Desktop.
dryscrape user agent demo
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