What's the difference between “browser posting

2019-08-30 05:31发布

I've asked one question about this a month ago, it's here: "post" method to communicate directly with a server.

And I still didn't get the reason why sometimes I get 404 error and sometimes everything works fine, I mean I've tried those codes with several different wordpress blogs. Using firefox or IE, you can post the comment without any problem whatever wordpress blog it is, but using python and "post" method directly communicating with a server I got 404 with several blogs. And I've tried to spoof the headers, adding cookies in the code, but the result remains the same. It's bugging me for quite a while... Anybody knows the reason? Or what code should I add to make the program works just like a browser such as firefox or IE etc ? Hopefully you guys would help me out!

2条回答
Emotional °昔
2楼-- · 2019-08-30 05:53

The blog may have some spam protection against this kind of posting. ( Using programmatic post without accessing/reading the page can be easily detected using javascript protection ). But if it's the case, I'm surprised you receive a 404...

Anyway, if you wanna simulate a real browser, the best way is to use a real browser remote controlled by python.

Check out WebDriver (http://seleniumhq.org/docs/09_webdriver.html) It has a python implementation and can run HtmlUnit, chrome, IE and Firefox browsers.

查看更多
混吃等死
3楼-- · 2019-08-30 06:16

You should use somthing like mechanize.

查看更多
登录 后发表回答