切换到宽版
  • 3682Read
  • 0Replay

Python 获取POST [复制链接]

上一主题 下一主题
离线Francis
 

只看楼主 倒序阅读 使用道具 楼主  posttime: 2017-07-23
— 本帖被 Francis 从 编程 移动到本区(2022-01-18) —

import signal
import urllib2
from bs4 import BeautifulSoup

def handler (signum,frame):
    print "rppost over time!"
    exit()

def post(url):
    try:
        req = urllib2.Request(url)
        req.add_header('User-Agent','Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/537.36')
        req.add_header('Connection','keep-alive')
        req.add_header('Accept','text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor())
        
        signal.signal(signal.SIGALRM,handler)
        signal.alarm(3)
        response = opener.open(req)
        signal.alarm(0)
        return response.read()
    except:
        return ""
快速回复
限100 字节
批量上传需要先选择文件,再选择上传
 
上一个 下一个