Dynamically Alter HTML Source

久未见 提交于 2020-01-15 10:57:14

问题


I am curious if there might be a way to dynamically alter source from a web page automatically.

For instance, I know the firebug plugin for Firefox allows the capability to modify the source and see the reaction in real-time. So, say I want to login to a particular form. Could I alter this dynamic source with a login name and password and enter the website in question via some automated script? If not, are there any potential alternatives to this approach that may fair better?

Thanks.


回答1:


If you want something which can automate IE browser, what I can recommend to you is: Watir and WatiN. Watir is developed in ruby while WatiN is developed in c#. They are both quite powerful, more than enough to meet your requirements.

If you have to use Python script. then I would recommend C# + WatiN + IronPython. You can write python scripts to call WatiN's dll. Please note that, IronPython is not the same as Python, it is based on microsoft's .net framework. Currently I don't know any pure python product which can do the same as WatiN and Watir.




回答2:


If you want to login to a website automatically you don't need to edit the source, you need to interact with the webserver. Try curl and use it to submit login details and fetch the resulting web page.




回答3:


for firefox automation, I recommend chickenfoot to you. It can meet your needs:

alter this dynamic source with a login name and password and enter the website in question via some automated script

But chechenfoot only supports up to firefox 3. If you want to support the newest version of firefox, you might have to get the source code and compile it yourself.




回答4:


If you can use Javascript, try:

document.write("HTML CODE HERE");

But if you need in Python, I think you can use REPLACE in the HTML Source Code.



来源:https://stackoverflow.com/questions/6560678/dynamically-alter-html-source

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!