Skip to content

Commit e287144

Browse files
authored
Readme improvements (#126)
1 parent e4f8e4c commit e287144

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

README.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Apify SDK for Python
22

3-
The Apify SDK for Python is the official library to create [Apify Actors](https://docs.apify.com/platform/actors) in Python.
4-
It provides useful features like actor lifecycle management, local storage emulation, and actor event handling.
3+
The Apify SDK for Python is the official library to create [Apify Actors](https://docs.apify.com/platform/actors)
4+
in Python. It provides useful features like Actor lifecycle management, local storage emulation, and Actor
5+
event handling.
56

67
If you just need to access the [Apify API](https://docs.apify.com/api/v2) from your Python applications,
78
check out the [Apify Client for Python](https://docs.apify.com/api/client/python) instead.
@@ -15,14 +16,22 @@ For usage instructions, check the documentation on [Apify Docs](https://docs.api
1516
```python
1617
from apify import Actor
1718
from bs4 import BeautifulSoup
18-
import requests
19+
from httpx import AsyncClient
1920

20-
async def main():
21+
async def main() -> None:
2122
async with Actor:
22-
input = await Actor.get_input()
23-
response = requests.get(input['url'])
23+
# Read the input parameters from the Actor input
24+
actor_input = await Actor.get_input()
25+
# Fetch the HTTP response from the specified URL
26+
async with AsyncClient() as client:
27+
response = await client.get(actor_input['url'])
28+
# Process the HTML content
2429
soup = BeautifulSoup(response.content, 'html.parser')
25-
await Actor.push_data({ 'url': input['url'], 'title': soup.title.string })
30+
# Push the extracted data
31+
await Actor.push_data({
32+
'url': actor_input['url'],
33+
'title': soup.title.string,
34+
})
2635
```
2736

2837
## What are Actors?
@@ -34,14 +43,16 @@ all the way up to scraping and processing vast numbers of web pages.
3443
They can be run either locally, or on the [Apify platform](https://docs.apify.com/platform/),
3544
where you can run them at scale, monitor them, schedule them, or publish and monetize them.
3645

37-
If you're new to Apify, learn [what is Apify](https://docs.apify.com/platform/about) in the Apify platform documentation.
46+
If you're new to Apify, learn [what is Apify](https://docs.apify.com/platform/about)
47+
in the Apify platform documentation.
3848

3949
## Creating Actors
4050

4151
To create and run Actors through Apify Console,
4252
see the [Console documentation](https://docs.apify.com/academy/getting-started/creating-actors#choose-your-template).
4353

44-
To create and run Python Actors locally, check the documentation for [how to create and run Python Actors locally](https://docs.apify.com/sdk/python/docs/overview/running-locally).
54+
To create and run Python Actors locally, check the documentation for
55+
[how to create and run Python Actors locally](https://docs.apify.com/sdk/python/docs/overview/running-locally).
4556

4657
## Guides
4758

0 commit comments

Comments
 (0)