예제 #1
0
    def get_permanent_wechat_article_url(self, sougou_url):
        """ 从搜狗的临时url获取永久url

        Args:
            sougou_url (str): "http://mp.weixin.qq.com/s?timestamp=1473815432&src=3&ver=1&signature=puOtJfG0mefG5o6Ls-bqDmML9ZjS5S6oDIhdUReNRm6*bIF9yINfCoXvB3btXzPEeUZvV8bdlSRTgKPx5Nsd6ZfzLK4Gv4X6z7te1EEo2azG3llx*rw*fxqXrKnwP2oqTTrNYxaRzM8cARFIbjPHVLpWdZGqNhyxsKoK5ozlXSk="

        Returns:
            msg_link (str): "http://mp.weixin.qq.com/s?__biz=MzI1OTAwNDc1OA==&mid=2652831837&idx=1&sn=3a93c0b6dfeef85e9b85bdac39f47bce&chksm=f1942064c6e3a9728f0bdc4d9bab481b7079c7c1d9ed32397295b45d0b02af839dafcc4b093e#rd";

        """
        time.sleep(random.randint(1, 10))
        curl_str = """
        curl 'http://mp.weixin.qq.com/s?timestamp=1473815432&src=3&ver=1&signature=puOtJfG0mefG5o6Ls-bqDmML9ZjS5S6oDIhdUReNRm6*bIF9yINfCoXvB3btXzPEeUZvV8bdlSRTgKPx5Nsd6ZfzLK4Gv4X6z7te1EEo2azG3llx*rw*fxqXrKnwP2oqTTrNYxaRzM8cARFIbjPHVLpWdZGqNhyxsKoK5ozlXSk=' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Connection: keep-alive' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36' --compressed
        """
        _, headers, _ = parse_curl_str(curl_str)
        headers['User-Agent'] = random_ua()
        r = requests.get(sougou_url)
        html = r.text
        try:
            msg_link = xhtml_unescape(extract('msg_link = "', '";', html))
        except Exception:
            self.logger.exception(html)
            msg_link = sougou_url
        self.logger.info('get permanent url: %s', msg_link)
        return msg_link
예제 #2
0
파일: guahao.py 프로젝트: sjl421/pyhome
def confirm(Cookie_str, smsVerifyCode):
    S = """
    curl 'http://www.bjguahao.gov.cn/order/confirm.htm' -H 'Cookie: SESSION_COOKIE=3cab1829cea36ddbceb17f7e; JSESSIONID=23672CA0BED9A20467098C5F4B95646F; Hm_lvt_bc7eaca5ef5a22b54dd6ca44a23988fa=1467855129,1468286722,1468372579,1468459884; Hm_lpvt_bc7eaca5ef5a22b54dd6ca44a23988fa=1468459953' -H 'Origin: http://www.bjguahao.gov.cn' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4' -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Referer: http://www.bjguahao.gov.cn/order/confirm/142-200039542-201105758-38174400.htm' -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' --data 'dutySourceId=38174400&hospitalId=142&departmentId=200039542&doctorId=201105758&patientId=217727400&hospitalCardId=081138697714&medicareCardId=&reimbursementType=1&smsVerifyCode=%s&isFirstTime=2&hasPowerHospitalCard=2&cidType=1&childrenBirthday=&childrenGender=2&isAjax=true' --compressed
    """ % smsVerifyCode
    url, headers, data = parse_curl_str(S)
    headers['Cookie']= Cookie_str
    r = requests.post(url, headers=headers, data=data)
    print(r.text)
예제 #3
0
 def update_headers(cls):
     cls.logger.info('*********updating cookies*********')
     _, headers, _ = parse_curl_str(cls.curl_str)
     headers['Cookie'] = cls.get_cookie_str()
     if headers['Cookie'] is None:
         change_ip()
         cls.update_headers()
     else:
         cls.headers = headers
예제 #4
0
class KankanDouDownloader(Downloader):
    curl_str = """
    curl 'http://kankandou.com/book/view/12678.html' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Referer: http://kankandou.com/login.html?uri=/book/view/12678.html' -H 'Cookie: cisession=2b040f9878b9a9e464e56bf831c3565d8e637e79; CNZZDATA1000201968=2121606612-1470262708-%7C1471877794; Hm_lvt_f805f7762a9a237a0deac37015e9f6d9=1471532383,1471532385,1471534944,1471681547; Hm_lpvt_f805f7762a9a237a0deac37015e9f6d9=1471881503' -H 'Connection: keep-alive' -H 'Cache-Control: max-age=0' --compressed
    """
    url, headers, data = parse_curl_str(curl_str)

    def get(self, *args, **kwargs):
        kwargs.setdefault('headers', self.headers)
        return super(KankanDouDownloader, self).get(*args, **kwargs)
예제 #5
0
파일: sg.py 프로젝트: PegasusWang/wechannel
 def update_headers(cls):
     cls.logger.info('*********updating cookies*********')
     _, headers, _ = parse_curl_str(cls.curl_str)
     headers['Cookie'] = cls.get_cookie_str()
     if headers['Cookie'] is None:
         change_ip()
         cls.update_headers()
     else:
         cls.headers = headers
예제 #6
0
파일: guahao.py 프로젝트: sjl421/pyhome
def get_qrcode():
    CURL_STR = """
    curl 'http://www.bjguahao.gov.cn/quicklogin.htm' -H 'Cookie: JSESSIONID=79657BDB664F5A7BF7F25EAE9AEC069A; SESSION_COOKIE=3cab1829cea36ddbceb17f7e; Hm_lvt_bc7eaca5ef5a22b54dd6ca44a23988fa=1467855129,1468286722,1468372579,1468459884; Hm_lpvt_bc7eaca5ef5a22b54dd6ca44a23988fa=1468459939' -H 'Origin: http://www.bjguahao.gov.cn' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4' -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Referer: http://www.bjguahao.gov.cn/dpt/appoint/142-200039542.htm' -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' --data 'mobileNo={}&password={}&yzm=&isAjax=true' --compressed
    """.format(mobileNo, password)
    url, headers_dict, data = parse_curl_str(CURL_STR)
    del headers_dict['Cookie']    # note must delete this Cookie before login
    with requests.Session() as s:
        r = s.post(url, headers=headers_dict, data=data)    # login
        print(r.text)
        r = s.post(url='http://www.bjguahao.gov.cn/v/sendorder.htm')
        print(r.text)
        # r = s.post(url=CONFIRM_URL, data=CONFIRM_DATA)
        # print(r.text)

    S = """
    curl 'http://www.bjguahao.gov.cn/order/confirm.htm' -H 'Cookie: SESSION_COOKIE=3cab1829cea36ddbceb17f7e; JSESSIONID=23672CA0BED9A20467098C5F4B95646F; Hm_lvt_bc7eaca5ef5a22b54dd6ca44a23988fa=1467855129,1468286722,1468372579,1468459884; Hm_lpvt_bc7eaca5ef5a22b54dd6ca44a23988fa=1468459953' -H 'Origin: http://www.bjguahao.gov.cn' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4' -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Referer: http://www.bjguahao.gov.cn/order/confirm/142-200039542-201105758-38174400.htm' -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' --data 'dutySourceId=38174400&hospitalId=142&departmentId=200039542&doctorId=201105758&patientId=217727400&hospitalCardId=081138697714&medicareCardId=&reimbursementType=1&smsVerifyCode=583293&isFirstTime=2&hasPowerHospitalCard=2&cidType=1&childrenBirthday=&childrenGender=2&isAjax=true' --compressed
    """
    url, _, data = parse_curl_str(S)
    headers = r.request.headers
    cookie_str = headers['Cookie']
    smsVerifyCode = raw_input('input smsVerifyCode:\n')
    confirm(cookie_str, smsVerifyCode)
예제 #7
0
def get_all_urls():
    res = []
    for page in range(1, 30):
        lagou_str = """
        curl 'http://www.lagou.com/jobs/positionAjax.json?city=%E5%8C%97%E4%BA%AC&needAddtionalResult=false' -H 'Cookie: tencentSig=7125489664; user_trace_token=20160425192327-031ce0e3075345a78ae06025f639b168; LGUID=20160425192327-21b06b83-0ad8-11e6-9d60-525400f775ce; ctk=1468641740; JSESSIONID=7FF0D2C2298B22582ACBB807C035AAA2; LGMOID=20160716120220-D5B70628E98E5A204FD0C6112C770633; _gat=1; PRE_UTM=; PRE_HOST=; PRE_SITE=; PRE_LAND=http%3A%2F%2Fwww.lagou.com%2F; index_location_city=%E5%8C%97%E4%BA%AC; SEARCH_ID=8549ce4a6dfd4f3e87db40bc5b1291d2; _ga=GA1.2.1486841592.1461583315; Hm_lvt_4233e74dff0ae5bd0a3d81c6ccf756e6=1468641738; Hm_lpvt_4233e74dff0ae5bd0a3d81c6ccf756e6=1468641749; LGSID=20160716120223-19e38457-4b0a-11e6-bb84-525400f775ce; LGRID=20160716120234-208876f0-4b0a-11e6-b12b-5254005c3644' -H 'Origin: http://www.lagou.com' -H 'X-Anit-Forge-Code: 0' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4' -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Referer: http://www.lagou.com/jobs/list_python?labelWords=&fromSearch=true&suginput=' -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' -H 'X-Anit-Forge-Token: None' --data 'first=true&pn={}&kd=python' --compressed
        """.format(page)
        print(lagou_str)
        url, headers, data = parse_curl_str(lagou_str)
        r = fetch_json(url, data=data, headers=headers)  # loads
        if r and r.status_code == 200:
            res.extend(parse_json(r.text))

    position_url = 'http://www.lagou.com/jobs/%s.html'
    return (position_url % str(_id) for _id in res)
예제 #8
0
파일: ininin.py 프로젝트: sjl421/pyhome
def query_product_info_dict(product_id=None):
    """ query_product    此请求直接可以拿到商品信息,之前没注意到这个请求。:(

    :param product_id: int or string of product id
    :returns: data dict
    """
    assert product_id
    s = """
    curl 'http://action.ininin.com/in_product_new/query_product?product_id=200106&jsoncallback=BEHBAAHHHAEAICGV&ininin=BEHBAAHHHAEAJUUY' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36' -H 'Accept: */*' -H 'Referer: http://www.ininin.com/product/200106.html' -H 'Cookie: _serviceQQ=http%3A%2F%2Fwpa.b.qq.com%2Fcgi%2Fwpa.php%3Fln%3D1%26key%3DXzkzODA2MjI0N180MjM3NDhfNDAwODYwMTg0Nl8yXw; _address=%E5%8C%97%E4%BA%AC%E5%B8%82%5E%E5%8C%97%E4%BA%AC%E5%B8%82%5E%E4%B8%9C%E5%9F%8E%E5%8C%BA; _gat=1; _ga=GA1.2.973205482.1470919907' -H 'Connection: keep-alive' -H 'Cache-Control: max-age=0' --compressed
    """
    url, header_dict, data = parse_curl_str(s)
    url = re.sub('product_id=(\d+)&', 'product_id=%s&' % str(product_id), url)
    r = requests.get(url, headers=header_dict, data=data)    # keyword params
    # BEHBAAHHHAEAICGV({"result":0,"msg":"","data":{"result":0,"msg":"查询成功","productId":200021,"categoryId":39,"categoryName":"经典","productName":"“新”名片","productImg":"http://cloud.ininin.com/1453727435050.jpg","title":"“新”名片_铜版纸名片设计_铜版纸名片制作_铜版纸名片报价_云印","keywords":"铜版纸名片设计,铜版纸名片制作,铜版纸名片报价","description":"高档300克铜版纸,具有手感厚重,笔直挺括,质地密实、高白度、设计表现强特点。报价:最便宜3.5元至最贵59元/盒(100张),多款铜版纸名片,5种可选铜版纸名片处理工艺。","pImages":"http://cloud.ininin.com/1453727455067.jpg,http://cloud.ininin.com/1453727457303.jpg,http://cloud.ininin.com/1453727459607.jpg,http://cloud.ininin.com/1453727472730.jpg,http://cloud.ininin.com/1453727468168.jpg","priceDesc":"8元/盒起","simpleDesc":"“新”名片【铜版纸】——案头常备的优质名片,满99包邮!","productDesc":"[{\"title\":\"下单流程\",\"content\":\"\u003cp style\u003d\\\"text-align: center;\\\"\u003e\u003cimg src\u003d\\\"http://cloud.ininin.com/1453727509640.jpg\\\"/\u003e\u003c/p\u003e\u003cp style\u003d\\\"text-align: center;\\\"\u003e\u003cimg src\u003d\\\"http://cloud.ininin.com/1453727519881.jpg\\\"/\u003e\u003c/p\u003e\u003cp style\u003d\\\"text-align: center;\\\"\u003e\u003cimg src\u003d\\\"http://cloud.ininin.com/1457590273025.jpg\\\"/\u003e\u003c/p\u003e\u003cp style\u003d\\\"text-align: center;\\\"\u003e\u003cimg src\u003d\\\"http://cloud.ininin.com/1470700220636.png\\\" style\u003d\\\"max-width:100%;\\\"/\u003e\u003c/p\u003e\u003cp\u003e\u003cbr/\u003e\u003c/p\u003e\u003cp\u003e\u003cbr/\u003e\u003c/p\u003e\"},{\"title\":\"产品介绍\",\"content\":\"\u003cdiv style\u003d\\\"text-align: center;\\\"\u003e\u003cimg src\u003d\\\"http://cloud.ininin.com/1453727574011.jpg\\\"/\u003e\u003c/div\u003e\"},{\"title\":\"使用场景\",\"content\":\"\"},{\"title\":\"规格参数\",\"content\":\"\"},{\"title\":\"下单须知\",\"content\":\"\"},{\"title\":\"物流说明\",\"content\":\"\"},{\"title\":\"售后服务\",\"content\":\"\"}]","baseInfoName":"材质类型_数量_成品尺寸-覆膜","preferntialInfo":"[{\"preferentialSort\":1,\"preferentialTitle\":\"优惠套餐\",\"preferentialDescription\":\"购买新名片印刷套餐,立享更多优惠\",\"preferentialLink\":\"http://design.ininin.com/category/131.html\"}]","addedServicesList":[],"params":{"300g铜版纸_1盒_90mm*54mm":{"覆膜":{"覆哑膜":1}},"300g铜版纸_2盒_90mm*54mm":{"覆膜":{"覆哑膜":1}},"300g铜版纸_5盒_90mm*54mm":{"覆膜":{"覆哑膜":1}},"300g铜版纸_10盒_90mm*54mm":{"覆膜":{"覆哑膜":1}},"300g铜版纸_20盒_90mm*54mm":{"覆膜":{"覆哑膜":1}},"300g铜版纸_40盒_90mm*54mm":{"覆膜":{"覆哑膜":1}},"300g铜版纸_100盒_90mm*54mm":{"覆膜":{"覆哑膜":1}}},"type":0,"standardType":0,"showType":0,"websiteShow":1,"homeShow":1,"homeShowIcon":1,"listShow":1,"listShowIcon":2,"minDistNum":-1,"targetId":"0","valuationMethod":0,"valuationValue":0.15,"productVariety":0}})
    content = r.content.decode('utf-8')
    content = content[content.find('(')+1: -2]
    return json.loads(content).get('data')
예제 #9
0
파일: ininin.py 프로젝트: sjl421/pyhome
def test():
    s = """curl 'http://action.ininin.com/in_quotation/get_price?ininin=BEGHFDGFECCCAEHR' -H 'Cookie: _serviceQQ=http%3A%2F%2Fwpa.b.qq.com%2Fcgi%2Fwpa.php%3Fln%3D1%26key%3DXzkzODA2MjI0N18zMjkyNjNfNDAwODYwMTg0Nl8yXw; _address=%E5%8C%97%E4%BA%AC%E5%B8%82%5E%E5%8C%97%E4%BA%AC%E5%B8%82%5E%E4%B8%9C%E5%9F%8E%E5%8C%BA; _gat=1; _ga=GA1.2.489086647.1467534150' -H 'Origin: http://www.ininin.com' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Cache-Control: max-age=0' -H 'Referer: http://www.ininin.com/product/200021.html' -H 'Connection: keep-alive' --data 'type=0&data=%5B%7B%22productId%22%3A%22200021%22%2C%22productParam%22%3A%22300g%E9%93%9C%E7%89%88%E7%BA%B8_1%E7%9B%92_90mm*54mm-%E8%A6%86%E5%93%91%E8%86%9C%22%2C%22productCount%22%3A%222%22%2C%22address%22%3A%22%E5%8C%97%E4%BA%AC%E5%B8%82%5E%E5%8C%97%E4%BA%AC%E5%B8%82%5E%E4%B8%9C%E5%9F%8E%E5%8C%BA%22%7D%5D' --compressed"""
    url, headers, data = parse_curl_str(s)
    r = requests.post(url, headers=headers, data=data)
    print(data)
    print(r.content)
예제 #10
0
파일: ininin.py 프로젝트: sjl421/pyhome
from random import randint
from functools import partial
from pprint import pprint

from bs4 import BeautifulSoup
import requests
from six.moves.urllib.parse import urlencode, quote

from lib._db import get_db
from web_util import parse_curl_str


BASE_URL = 'http://www.ininin.com/'
CURL_STR = """curl 'http://www.ininin.com/' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Connection: keep-alive' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36' --compressed"""
GET_PRICE_CURL_STR = """curl 'http://action.ininin.com/in_quotation/get_price?ininin=BEGHFDGFECCCAEHR' -H 'Cookie: _serviceQQ=http%3A%2F%2Fwpa.b.qq.com%2Fcgi%2Fwpa.php%3Fln%3D1%26key%3DXzkzODA2MjI0N18zMjkyNjNfNDAwODYwMTg0Nl8yXw; _address=%E5%8C%97%E4%BA%AC%E5%B8%82%5E%E5%8C%97%E4%BA%AC%E5%B8%82%5E%E4%B8%9C%E5%9F%8E%E5%8C%BA; _gat=1; _ga=GA1.2.489086647.1467534150' -H 'Origin: http://www.ininin.com' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Cache-Control: max-age=0' -H 'Referer: http://www.ininin.com/product/200021.html' -H 'Connection: keep-alive' --data 'type=0&data=%5B%7B%22productId%22%3A%22200021%22%2C%22productParam%22%3A%22300g%E9%93%9C%E7%89%88%E7%BA%B8_1%E7%9B%92_90mm*54mm-%E8%A6%86%E5%93%91%E8%86%9C%22%2C%22productCount%22%3A%222%22%2C%22address%22%3A%22%E5%8C%97%E4%BA%AC%E5%B8%82%5E%E5%8C%97%E4%BA%AC%E5%B8%82%5E%E4%B8%9C%E5%9F%8E%E5%8C%BA%22%7D%5D' --compressed"""
_, HEADERS, _ = parse_curl_str(CURL_STR)
requests.get = partial(requests.get, headers=HEADERS)
_, HEADERS, _ = parse_curl_str(GET_PRICE_CURL_STR)
requests.post = partial(requests.post, headers=HEADERS)


def get_all_product_url(url=BASE_URL):
    r = requests.get(url)
    html = r.content.decode('utf-8')
    soup = BeautifulSoup(html, 'lxml')

    category_tag = soup.find('div', id='nav_category')
    href_tag_list = category_tag.find_all('a')
    for href_tag in href_tag_list:
        href = href_tag.get('href')
        if href and href.startswith(r'http://www.ininin.com/product'):
예제 #11
0
 def get_headers(cls):
     url, headers, data = parse_curl_str(cls.curl_str)
     del headers['Cookie']
     return headers
예제 #12
0
파일: guahao.py 프로젝트: sjl421/pyhome

"""
http://www.bjguahao.gov.cn/
"""

import _env
from .config import mobileNo, password
import requests
from pprint import pprint
from web_util import parse_curl_str

CONFIRM_STR = """
curl 'http://www.bjguahao.gov.cn/order/confirm.htm' -H 'Cookie: SESSION_COOKIE=3cab1829cea36ddbceb17f7e; JSESSIONID=23672CA0BED9A20467098C5F4B95646F; Hm_lvt_bc7eaca5ef5a22b54dd6ca44a23988fa=1467855129,1468286722,1468372579,1468459884; Hm_lpvt_bc7eaca5ef5a22b54dd6ca44a23988fa=1468459953' -H 'Origin: http://www.bjguahao.gov.cn' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4' -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Referer: http://www.bjguahao.gov.cn/order/confirm/142-200039542-201105758-38174400.htm' -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' --data 'dutySourceId=38174400&hospitalId=142&departmentId=200039542&doctorId=201105758&patientId=217727400&hospitalCardId=081138697714&medicareCardId=&reimbursementType=1&smsVerifyCode=583293&isFirstTime=2&hasPowerHospitalCard=2&cidType=1&childrenBirthday=&childrenGender=2&isAjax=true' --compressed
"""
CONFIRM_URL, _, CONFIRM_DATA = parse_curl_str(CONFIRM_STR)


def get_qrcode():
    CURL_STR = """
    curl 'http://www.bjguahao.gov.cn/quicklogin.htm' -H 'Cookie: JSESSIONID=79657BDB664F5A7BF7F25EAE9AEC069A; SESSION_COOKIE=3cab1829cea36ddbceb17f7e; Hm_lvt_bc7eaca5ef5a22b54dd6ca44a23988fa=1467855129,1468286722,1468372579,1468459884; Hm_lpvt_bc7eaca5ef5a22b54dd6ca44a23988fa=1468459939' -H 'Origin: http://www.bjguahao.gov.cn' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4' -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Referer: http://www.bjguahao.gov.cn/dpt/appoint/142-200039542.htm' -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' --data 'mobileNo={}&password={}&yzm=&isAjax=true' --compressed
    """.format(mobileNo, password)
    url, headers_dict, data = parse_curl_str(CURL_STR)
    del headers_dict['Cookie']    # note must delete this Cookie before login
    with requests.Session() as s:
        r = s.post(url, headers=headers_dict, data=data)    # login
        print(r.text)
        r = s.post(url='http://www.bjguahao.gov.cn/v/sendorder.htm')
        print(r.text)
        # r = s.post(url=CONFIRM_URL, data=CONFIRM_DATA)
        # print(r.text)
예제 #13
0
파일: sg.py 프로젝트: PegasusWang/wechannel
 def get_headers(cls):
     url, headers, data = parse_curl_str(cls.curl_str)
     del headers['Cookie']
     return headers
예제 #14
0
파일: oanda.py 프로젝트: sjl421/pyhome
#!/usr/bin/env python
# -*- coding:utf-8 -*-

import _env
import requests
from web_util import parse_curl_str



s = """curl 'http://www.oanda.com/lang/cns/currency/historical-rates/update?quote_currency=USD&end_date=2016-1-27&start_date=1990-1-1&period=weekly&display=absolute&rate=0&data_range=c&price=mid&view=graph&base_currency_0=CNY&base_currency_1=&base_currency_2=&base_currency_3=&base_currency_4=&' -H 'Cookie: price=mid; period=weekly; data_range=c; mru_base1=EUR%2CUSD%2CGBP%2CCAD%2CAUD; mru_base2=EUR%2CUSD%2CGBP%2CCAD%2CAUD; mru_base3=EUR%2CUSD%2CGBP%2CCAD%2CAUD; mru_base4=EUR%2CUSD%2CGBP%2CCAD%2CAUD; mru_quote=EUR%2CUSD%2CGBP%2CCAD%2CAUD; mru_base0=CNY%2CEUR%2CUSD%2CGBP%2CCAD; base_currency_0=CNY; start_date=1990-01-01; end_date=2016-01-27; opc_id=DE9419D4-C4CA-11E5-94D8-9567B63EDD35; optimizelyEndUserId=oeu1453881134343r0.5306167961098254; optimizelySegments=%7B%22225865993%22%3A%22gc%22%2C%22227082520%22%3A%22direct%22%2C%22227082521%22%3A%22false%22%2C%222289461220%22%3A%22none%22%7D; optimizelyBuckets=%7B%7D; tc=1; _ga=GA1.2.1415034805.1453881137; _gat=1; __atuvc=1%7C4; __atuvs=56a8772e2a63f487000; hcc_session=1453881398' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.82 Safari/537.36' -H 'Accept: text/javascript, text/html, application/xml, text/xml, */*' -H 'Referer: http://www.oanda.com/lang/cns/currency/historical-rates/' -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' -H 'X-Prototype-Version: 1.7' --compressed"""
url, headers, data = parse_curl_str(s)

print(requests.get(url, headers=headers, data=data).content)
예제 #15
0
파일: chinapub.py 프로젝트: sjl421/pyhome
def get_header_dict():
    china_str = """curl 'http://search.china-pub.com/search/getpanicbuy.aspx?key=qg' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36' -H 'Accept: */*' -H 'Referer: http://search.china-pub.com/s/?key1=%bc%c6%cb%e3%bb%fa%cc%d8%bc%db&pz=1&type=59&page=1' -H 'Cookie: ASP.NET_SessionId=iagt3kbcxj1fjx55ex0gns55; __utmz=268923182.1460293356.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); CViewProductHistory=; selecthistory=%bc%c6%cb%e3%bb%fa%cc%d8%bc%db%7c%cc%d8%bc%db%ca%e9; Hm_lvt_c68f8a95996223c018465c5143d0bdea=1460293359; Hm_lpvt_c68f8a95996223c018465c5143d0bdea=1460293389; __utma=268923182.187256519.1460293356.1460293356.1460293356.1; __utmc=268923182; __utmb=268923182.5.10.1460293356; ordercount=0; cartbooknum=0; hurl=%2Cw/%2Cs/%25cc%25d8%25bc%25db%25ca%25e9%26type%3D%26pz%3D1%2Cs/%25bc%25c6%25cb%25e3%25bb%25fa%25cc%25d8%25bc%25db%26type%3D%26pz%3D1%2Cs/%25bc%25c6%25cb%25e3%25bb%25fa%25cc%25d8%25bc%25db%26pz%3D1%26type%3D59%2Cs/%25bc%25c6%25cb%25e3%25bb%25fa%25cc%25d8%25bc%25db%26pz%3D1%26type%3D59%26page%3D2%2Cs/%25bc%25c6%25cb%25e3%25bb%25fa%25cc%25d8%25bc%25db%26pz%3D1%26type%3D59%26page%3D1' -H 'Connection: keep-alive' -H 'If-Modified-Since: 0' -H 'Cache-Control: no-cache' --compressed"""
    _, headers, data = parse_curl_str(china_str)
    return headers