直接不隐讳的直接说了,想写个 python 脚本帮朋友申请签证名额,
遇到的问题
- 每次 get,得到的都是 noscript 的提示,需要 JS
- 对于非本地 IP 有验证码
我的尝试
mechanize
import sys
import mechanize
url ='xxx'
response2=br.open(url)
request = br.request
print (response2.info())
print (response2.read())
output:
Cache-Control: no-store, must-revalidate, no-cache, max-age=0
Content-Type: text/html
Connection: close
Vary: Accept-Encoding
Pragma: no-cache
Expires: -1
CacheControl: no-cache
X-UA-Compatible: IE=edge
Content-Type: text/html; charset=utf-8
... more content ...
<noscript>Please enable JavaScript to view the page content.</noscript>
</head><body>
</body></html>
selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
url= 'xxx'
driver.get(url)
print driver.context
print driver.title
print driver.page_source
driver.close()
output
nosctipt 同上
Refes
- 目标站点及详细问题,请见 so https://stackoverflow.com/questions/44562212/fetching-web-page-but-need-javascript-to-view-page-content
- 目标 url 在 comment 里