Frias
Frias

Reputation: 11281

How can I access any element in a web page with Python?

I would like to access any element in a web page. I know how to do that when I have a form (form = cgi.FieldStorage()), but not when I have, for example, a table.

How can I do that?

Thanks

Upvotes: 0

Views: 194

Answers (4)

seriyPS
seriyPS

Reputation: 7102

You can access only data, posted by form (or as GET parameters).

So, you can extract data you need using JavaScript and post it through form

Upvotes: 0

nmichaels
nmichaels

Reputation: 50943

The way to access a table is to parse the HTML. This is different from accessing form data, in that it's not dynamic. Since you mentioned CGI, I'm assuming you're working on the server side of things and that you have the ability to serve whatever content you want. So you could use whatever data you're representing in the table in its raw form before turning it into HTML too.

Upvotes: 0

Rafe Kettler
Rafe Kettler

Reputation: 76955

HTML parsing using either HTMLParser or Beautiful Soup if you're trying to get data from a web page. You can't really write data to an HTML table like you could do with CGI and forms, so I'm hoping this is what you want.

I personally recommend Beautiful Soup if you want intelligent parsing behavior.

Upvotes: 0

rtpg
rtpg

Reputation: 2439

If you are familiar with javascript, you should be familiar with the DOM. This should help you to get the information you want, seeing how this parses HTML, among other things. Then it's up to you to extract the information you need

Upvotes: 1

Related Questions