login - How can I use Python to log in to a website and perform actions in it? -


these steps need automatize:

1) log in

2) select option drop down menu (to acces list of products)

3) search on search field (the product looking for)

4) click link (to open product's options)

5) click link(to compile .pdf files relevant said product in bigger .pdf)

6) wait .pdf load , download it.(save .pdf on machine name of product file name)

i want know if possible. if is, can find how it?

is pivotal there actual clicking involved? if you're looking download pdfs suggest use requests library. might want consider using scrapy.

in terms of searching on site, may want use fiddler capture http post request , replicate in python.

here code might useful starting place - these functions login server , download target file.

def login():     login_url = 'http://www.example.com'     payload = 'usr=username&pwd=password'     connection = requests.session()     post_login = connection.post(data=payload,         url=login_url,         headers=main_headers,         proxies=proxies,         allow_redirects=true)  def download():     directory = "c:\\example\\"     url = "http://example.com/download.pdf"     filename = directory + '\\' + url[url.rfind("/")+1:]     r = connection.get(url=url,                        headers=main_headers,                        proxies=proxies)     file_size = int(r.headers["content-length"])     block_size = 1024     mode = 'wb'     print "\tdownloading: %s [%skb]" % (filename, int(file_size/1024))     if r.status_code == 200:         open(filename, mode) f:             chunk in r.iter_content(block_size):                 f.write(chunk) 

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

image - ClassNotFoundException when add a prebuilt apk into system.img in android -