Python3 - interacting with HTML pages help

+4 James Kon · October 30, 2015
I need a plugin that allows me to do these things:

  • Read HTML codes

  • Simulate the clicking of a button

  • Be able to submit forms from a HTML page in the background of the computer

  • Can enter text into input boxes

  • Able to simulate the pressing of buttons, like pressing the enter button



Making it be in the background, and not maximized is optional, but would prefer that the user not see it.inter

Post a Reply

Replies

- page 1
Oldest  Newest  Rating
0 James Kon · November 2, 2015
Thank you so much!
+2 alex constantin · November 2, 2015
Good to know, I think the final step is this:

phrase = "Just a moment..."
encodedPhrase = bytes(phrase.encode("utf-8"))
0 James Kon · November 1, 2015
It comes up with another error,

phrase = bytes("Just a moment...")

TypeError: string argument without an encoding

One step closer to the solution though.
0 alex constantin · November 1, 2015
If this does not work, you can also try:

while "Just a moment..." in page1.decode():
#do code
+2 alex constantin · November 1, 2015
Try this:

phrase = bytes("Just a moment...")

while phrase in page1:
#do code
0 James Kon · November 1, 2015
str is refering to it being a string, it already is a string. It needs to be converted in to a bytes-like object, whatever that is...

I did try that by the way, I got the same error:

a bytes-like object is required, not 'str'
0 alex constantin · October 31, 2015
Try converting the page1 variable to a string maybe? Not sure, but try str(page1)
0 James Kon · October 31, 2015
I went back to selenium, as well as watched the tutorial Alex gave me. I ran into another problem.

After getting the source code from the website, to check the title of it I am doing this:


page = c.get(url)
page1 = page.content
var1 = 0
while "Just a moment..." in page1:
var1 += 1


Page1 is the variable with the source code of the website by the way, however when I run it I get this error:

while "Just a moment..." in page1:

TypeError: a bytes-like object is required, not 'str'


I tried looking on other websites for help of this, but in their examples of turning things into a byte object doesn't involve variables.
0 James Kon · October 31, 2015
alex constantin,

In the tutorial it shows you looking at the token after you had logged in, the website I am using does not have a login/ name passed through, and if it does it is hidden. Is there a way to search all the information passed through? As there is quite a bit to look through.

Edit: I found the problem, directly after logging in, it would take me to another page before it took me to the actual website. I got it though.
+2 alex constantin · October 30, 2015
A tutorial explaining my previous post:  https://www.youtube.com/watch?v=eRSJSKG4mDA
  • 1
  • 2

Python

107,322 followers
About

This section is all about snakes! Just kidding.

Links
Moderators
Bucky Roberts Administrator