You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For the integration to work you'll need to install `aiohttp` library, use `Python 3.6` version or higher and Residential Proxies. <br> If you don't have `aiohttp` library, you can install it by using `pip` command:
9
+
10
+
For the integration to work you'll need to install `aiohttp` library, use `Python 3.6`
11
+
version or higher and Residential Proxies. <br> If you don't have `aiohttp` library,
12
+
you can install it by using `pip` command:
13
+
6
14
```bash
7
15
pip install aiohttp
8
16
```
17
+
9
18
You can get Residential Proxies here: https://oxylabs.io/products/residential-proxy-pool
10
19
11
20
## Proxy Authentication
21
+
12
22
There are 2 ways to authenticate proxies with `aiohttp`.<br>
13
-
The first way is to authorize and pass credentials along with the proxy URL using `aiohttp.BasicAuth`:
23
+
The first way is to authorize and pass credentials along with the proxy URL
24
+
using `aiohttp.BasicAuth`:
25
+
14
26
```python
27
+
import aiohttp
28
+
15
29
USER="user"
16
30
PASSWORD="pass"
17
31
END_POINT="pr.oxylabs.io:7777"
18
32
19
33
asyncdeffetch():
20
34
asyncwith aiohttp.ClientSession() as session:
21
-
proxy_auth = aiohttp.BasicAuth(USER, PASS)
22
-
asyncwith session.get("http://ip.oxylabs.io",
23
-
proxy="http://pr.oxylabs.io:7777",
24
-
proxy_auth=proxy_auth
35
+
proxy_auth = aiohttp.BasicAuth(USER, PASSWORD)
36
+
asyncwith session.get(
37
+
"http://ip.oxylabs.io",
38
+
proxy="http://pr.oxylabs.io:7777",
39
+
proxy_auth=proxy_auth ,
25
40
) as resp:
26
41
print(await resp.text())
27
42
```
43
+
28
44
The second one is by passing authentication credentials in proxy URL:
45
+
29
46
```python
47
+
import aiohttp
48
+
30
49
USER="user"
31
50
PASSWORD="pass"
32
51
END_POINT="pr.oxylabs.io:7777"
33
52
34
53
asyncdeffetch():
35
54
asyncwith aiohttp.ClientSession() as session:
36
-
asyncwith session.get("http://ip.oxylabs.io",
37
-
proxy=f"http://{USER}:{PASSWORD}@{END_POINT}"
55
+
asyncwith session.get(
56
+
"http://ip.oxylabs.io",
57
+
proxy=f"http://{USER}:{PASSWORD}@{END_POINT}",
38
58
) as resp:
39
59
print(await resp.text())
40
60
```
41
-
In order to use your own proxies, adjust `user` and `pass` fields with your Oxylabs account credentials.
61
+
62
+
In order to use your own proxies, adjust `user` and `pass` fields with your
63
+
Oxylabs account credentials.
42
64
43
65
## Testing Proxies
66
+
44
67
To see if the proxy is working, try visiting https://ip.oxylabs.io.
45
-
If everything is working correctly, it will return an IP address of a proxy that you're currently using.
68
+
If everything is working correctly, it will return an IP address of a proxy
69
+
that you're currently using.
46
70
47
71
## Sample Project: Extracting Data From Multiple Pages
48
-
To better understand how residential proxies can be utilized for asynchronous data extracting operations, we wrote a sample project to scrape product listing data and save the output to a `CSV` file. The proxy rotation allows us to send multiple requests at once risk-free – meaning that we don't need to worry about CAPTCHA or getting blocked. This makes the web scraping process extremely fast and efficient – now you can extract data from thousands of products in a matter of seconds!
72
+
73
+
To better understand how residential proxies can be utilized for asynchronous
74
+
data extracting operations, we wrote a sample project to scrape product listing
75
+
data and save the output to a `CSV` file. The proxy rotation allows us to send
76
+
multiple requests at once risk-free – meaning that we don't need to worry about
77
+
CAPTCHA or getting blocked. This makes the web scraping process extremely fast
78
+
and efficient – now you can extract data from thousands of products in a matter
print(f"\nExtracted data can be found at {os.path.join(os.getcwd(), filename)}")
116
158
```
117
-
If you want to test the project's script by yourself, you'll need to install some additional packages. To do that, simply download `requirements.txt`fileand use `pip` command:
159
+
160
+
If you want to test the project's script by yourself, you'll need to install
161
+
some additional packages. To do that, simply download `requirements.txt` file
162
+
and use `pip` command:
163
+
118
164
```bash
119
165
pip install -r requirements.txt
120
166
```
121
-
If you're having any trouble integrating proxies with `aiohttp` and this guide didn't help you - feel free to contact Oxylabs customer support at support@oxylabs.io.
167
+
168
+
If you're having any trouble integrating proxies with `aiohttp` and this guide
169
+
didn't help you - feel free to contact Oxylabs customer support at support@oxylabs.io.
0 commit comments