Modify HTML data

Peter Hansen peter at engcorp.com
Sun Nov 6 15:16:42 EST 2005


Swarna wrote:
> Peter Hansen wrote:
>>Swarna wrote:
>>>I am using scp in python to copy a html file on remote server, to my
>>>local machine. Now, i need to update this html file in my local machine
>>>( by adding a new Hyperlink to the existing table od hyperlinks ) and
>>>copy it back (overwriting the old copy ) to the remote server.
>>
>>If you are using scp to copy the file from the remote server in the
>>first place, what's stopping you from using scp to copy it back?
> 
> I might be vague in expressing my problem.....the problem is not with
> scp. What i need is how to modify the html file in my local machine
> that i got from remote server.

Ah, so all that stuff about scp was just to distract us from the real 
problem? <wink>

Okay, so Lorenzo's advice is fine: grab an HTML parser and use that to 
figure out where things are.  Or if the problem is defined simply 
enough, you could use a regular expression (re module).  BeautifulSoup 
is often recommended when the HTML is not necessarily very clean...

Personally, I'd start with an re and move on from there only if that was 
for some reason not sufficient.

-Peter



More information about the Python-list mailing list