python 爬虫 伪造浏览器

作者: cayman 分类: 编程技术 发布时间: 2017-04-08 15:17

#!/usr/bin/python

# -*- coding:utf-8 -*-

#作者:尹志强

#邮箱:dr_cayman@163.com

#博客地址:blog.ouoshop.com

# from apscheduler.schedulers.blocking import BlockingScheduler

# from datetime import datetime

import HTMLParser

import urlparse

import urllib

import urllib2

import cookielib

import string

import re

import uuid

import sys

import re

import json

import time

import os

import threading

import thread

hosturl="https://vimeo.com/"

cj = cookielib.LWPCookieJar()

cookie_support = urllib2.HTTPCookieProcessor(cj)

opener = urllib2.build_opener(cookie_support, urllib2.HTTPHandler)

urllib2.install_opener(opener)

h = urllib2.urlopen(hosturl)

send_headers = {

'Host':'vimeo.com',

'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0',

'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',

'Connection':'keep-alive',

'Accept-Language': 'zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3',

'Upgrade-Insecure-Requests': '1',

'Cache-Control': 'max-age=0',

}

req = urllib2.Request("https://vimeo.com/search?q=w",headers=send_headers)

response = urllib2.urlopen(req)

k=response.read()

print k

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注