def callback(ch, method, properties, body):
    """
    {'type': '010000', 'square_list': [73.010906, 44.471043, 73.510906, 43.971043]}
    :param ch:
    :param method:
    :param properties:
    :param body:
    :return:
    """
    api_key = method.consumer_tag
    trip.run(partial(asyn_message,body,api_key))
Ejemplo n.º 2
0
def request_amap(square_, type_, api_key):
    """
    apmap_result_json:pois
    amap_page_url:分页url
    amap_split: 等待切分
    :param square_:
    :param type_:
    :return:
    """
    square_ = str(square_[0]) + ',' + str(square_[1]) + ';' + str(
        square_[2]) + ',' + str(square_[3])
    print(square_)
    url = 'http://restapi.amap.com/v3/place/polygon?polygon=' + square_ + ';&types=' + type_ + '&output=JSON&key=' + \
          api_key + '&offset=50'
    trip.run(partial(requests_a, url, square_, type_))
Ejemplo n.º 3
0
 header = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.78 Safari/537.36'}
 localtime = str(datetime.datetime.now().year) + str(datetime.datetime.now().month) + str(datetime.datetime.now().day)#used to name files.
 ITL = 0
 ASNinfolist = []
 ASNlist = []
 PORTlist = []
 IPlist = [] 
 valid_proxy = []
 """
 These lines does the job of reading the proxies we got yesterday and re-test them.
 """
 j = open('allproxy.txt', 'r')  
 allproxy = j.readlines()
 for n in range(0,len(URL_SET)):
     if ITL <= len(URL_SET)-2:
         trip.run(main)
 print(len(allproxy))
 trip.run(test_only)
 valid_proxy = list(set(valid_proxy))
 j.close()
 """
 Write all useful IPs into "allproxy.txt" file.
 """
 f = open('allproxy.txt', 'w')
 for each in valid_proxy:
     f.write(each+'\n')
 f.close()
 """
 Used asyncio to speed up the process of checking ASN info.
 """      
 loop = asyncio.get_event_loop()
Ejemplo n.º 4
0
# -*- coding: utf-8 -*-
"""
@Time: 2018/1/22
@Author: songhao
@微信公众号: zeropython
@File: trip模块.py
"""
import trip


def main():
    r = yield trip.get('https://httpbin.org/get')
    print(r.content)


trip.run(main)
Ejemplo n.º 5
0
# 使用普通的 Requests
# import requests
#
# url = "http://httpbin.org"
# s = requests.Session()
#
# def fetch(times=10):
#     s.get("%s/cookies/set?name=value" % url)
#     r = [s.get("%s/get" % url) for i in range(times)]
#     print(r)
#
# fetch()

# 使用 Trip
import trip
url = "http://httpbin.org"
s = trip.Session()


@trip.coroutine
def fetch(times=10):
    s.get("%s/cookies/set?name=value" % url)
    r = [s.get("%s/get" % url) for i in range(times)]
    print(r)


trip.run(fetch)
def callback(ch, method, properties, body):
    trip.run(partial(asyn_message, body))
    ch.basic_ack(delivery_tag=method.delivery_tag)