Pressing a submit button in python using requests - python

So i want to check if my grades has been uploded, to do that i need to log in a website and then check if it has been changed.
the thing is after you log in you have two buttons: "agree" and "dont agree"
and when i try to press it, the website gives me an error message "wrong use
If you use a Personal Firewall, please deactivate it"
I'll upload my code in few hours
The website's code
Any help would be grateful.

You can use python-selenium to press buttons, you can also hide the browser instance.

Like #e4c5 said, you can really push button by python. As for me, the DevTools of Chrome does help a lot.
Here's the manual of the DevTools.
The 'Network' tab in DevTools will tell you all the requests and resources in the web page.If you want to see the detail request of the button-pushing action, You can firstly push the button and then see the new request shown in 'Network' tab.

You have to put Referer in the headers. This is how to bypass the university's check. Look at the original request (via Chrome dev tools), and copy the referrer into your request.

Related

How to talk with alert from page and not browser with Selenium

This is what the alert looks like. It reads: The proxy it3.prmsrvs.com is requesting a username and password I have a program in Selenium that automates a certain amount of stuff on a website.
For some reason (this has been encountered also by my colleagues when using the browser normally without automation) there is the possibility of a pop-up showing in the webpage at a random point.
My program's objective is to load a page, get a list of all the elements corresponding to a specific tag and then click on them one by one. They all open in a new tab.
There is the possibility of a pop-up to show in the page after closing one of the tabs.
This pop-up asks for a login but all I have to do is dismiss it and the page will keep working like always.
Now, I've seen people using driver.switch_to.alert.dismiss() but this doesn't seem to work on this page.
I checked the function on a very basic js alert and the dismiss works perfectly, so I think it's the type of alert that is the issue.
I can't inspect the page so I don't know how to retrieve the iFrame of this alert. (I saw this as a possible solution online)
What should I do?

How to login BarChart website with Python?

I try to log in https://www.barchart.com/ with python.
In order to find out the required parameters for logging in, I used Chrome/Firefox to inspect the website to see what parameters were listed in POST.
However, I could not find any.
Then how can I login it with python?
What I did:
Opened FireFox Web Developer
Inputted my username and password
After clicking "Log In", the following pop-up ad will show up.
Snapshot of the pop-up Ad
I left the pop-up alone, and just monitored the message returned under Network tab of Web Developer.
Found all the following POST messages and checked HEADERS
Snapshot of POST messages
However, none of messages is related to Log In, even BarChart.com
Any idea?
Thanks a lot!

Force closure of the popup on telegram “Open this link?”

When i use html formatting in a post and i create a link, Telegram show a popup before open the link. There is a script or something that force closure of the popup and open the link immediatly?
I don't want insert the link without HTML.
I press the enter key down(which I duplicated/remapped to the CapsLock key with Autohotkey) before I click a link. It worked easy & fortunate that there are no weird things will be triggered in the whole process.
There are no ways to close this popup. Telegram shows this for security reasons.
If you send the full URL, Telegram won't show this message.

Craigslist selenium diagnose what's happening

https://sfbay.craigslist.org/sfc/rts/d/san-francisco-new-mortgages-reverse/6908455741.html
How do I diagnose what's happening when I click the buttons "reply" -> "show phone number"?
There is this popup and loading button. I would like to see what is being sent from the browser to the server when clicking the first and second button. The source code is obviously changing dynamically so it is not practical to track by inspecting the source. I imagine there's a plugin or some tool to intercept or read the requests.
You can capture the requests using Fiddler, it captures http/https requests, and help you understand how to mimic the functionality you're looking for.
In Chrome or Firefox you could open the console and simply see the network traffic generated by a button.
With your example, you can see there is a call to the API at the following address:
https://sfbay.craigslist.org/contactinfo/sfo/rts/6908455741
Once you analyzed it, you can script the behaviour with Selenium and grab the data.

Is there a way in Selenium to post a copy paste protected password field?

I am trying to build a program to automatically upload documents onto a site 1 by 1 as the website administers won't give me access to their database.
My first problem arose just from trying to log into the system. I found that when I use,
elem = driver.find_element_by_name("q")
elem.send_keys("pycon")
it will copy paste "pycon" into the form. The form however is copy-paste protected and will never let me input into the form field.
The other problem arises when I use my browser to remember my username/password. When I run the script the fields are empty when it loads, so I can't submit(even if I implicitly tell it to wait 30 seconds for the browser to load).
Lastly, if I am already logged in the program will open a new window and ask for login/password again!
Is there anyway around any of this?
Is there a function to force selenium to type out each letter seperately? Is there a way to add my firefox profile on startup to force the rememberance of my username/password? Is there a way to have my webdriver open up another tab instead of a new window in firefox?
Any help would be appreciated! I need to get this done by Friday, thanks!
I am a dummy! I was using send_keys(Keys.ENTER) before my password was entered and it was erroring out. I apologize thanks for the quick responses though!

Categories