Reptile Chapter IV + single-threaded asynchronous multi-task coroutine

+ Single-threaded asynchronous multi-task coroutine: asyncio

Event loop loop: infinite loop object, event loop will eventually need some special function register to the event loop

     Special functions: keyword function is modified ansyc

Coroutine: an object in nature, can be registered coroutine object to the event loop,

Task objects: the package is further an object of the coroutine.

Binding callback (callback function that is executed after the completion of the implementation of special functions): task.add_done_callback (func)

  - FUNC (Task): Task parameter indicates the task object is bound

    - task.result () Returns the value of the special task is to return the interior of the object corresponding to the function

    - callback function is used as a multi-resolution method crawlers (and is parsed data label location)

await: in the implementation of the task function, if there is a blockage, you must add a modified await in front

Asynchronous operation reflects:

  When a plurality of co-routines objects into the event loop, open loop event, cycles through its internal coroutine execution objects.

  If the event loop object when a coroutine execution of a target, a blockage has occurred, the event will cycle to the next coroutine objects

aiohttp Module : supports asynchronous web request module  View Chinese document  Click here

Environmental installation: aiohttp
How to disguise UA:
    session.get(url=url,headers=headers)
Parameters of camouflage:
    session.get(url=url ,headers=headers ,data/params)
Proxy ip:
    session.get (url = url, headers = headers, proxy = 'http: // Agent ip: port Agent')

 

Guess you like

Origin www.cnblogs.com/zty1304368100/p/11025262.html