-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Cron Jobs | ||
|
||
Use a cron job that can run any time of day to gather website data. | ||
|
||
```python | ||
import asyncio | ||
from spider_rs import Website | ||
|
||
class Subscription: | ||
def __init__(self): | ||
print("Cron Created...") | ||
def __call__(self, page): | ||
print(page.url + " - status: " + str(page.status_code)) | ||
|
||
async def main(): | ||
website = Website("https://choosealicense.com").with_cron("1/5 * * * * *").build() | ||
handle = await website.run_cron(Subscription); | ||
|
||
asyncio.run(main()) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Page | ||
|
||
A single page on a website, useful if you just the root url. | ||
|
||
## New Page | ||
|
||
Get a new page with content. | ||
|
||
The first param is the url, followed by if subdomains should be included, and last to include TLD's in links. | ||
|
||
Calling `page.fetch` is needed to get the content. | ||
|
||
```python | ||
import asyncio | ||
from spider_rs import Page | ||
|
||
async def main(): | ||
page = Page("https://choosealicense.com") | ||
page.fetch() | ||
|
||
asyncio.run(main()) | ||
``` | ||
|
||
## Page Links | ||
|
||
get all the links related to a page. | ||
|
||
```python | ||
import asyncio | ||
from spider_rs import Page | ||
|
||
async def main(): | ||
page = Page("https://choosealicense.com") | ||
page.fetch() | ||
links = page.get_links() | ||
print(links) | ||
asyncio.run(main()) | ||
``` | ||
|
||
## Page Html | ||
|
||
Get the markup for the page or HTML. | ||
|
||
```python | ||
import asyncio | ||
from spider_rs import Page | ||
|
||
async def main(): | ||
page = Page("https://choosealicense.com") | ||
page.fetch() | ||
links = page.get_html() | ||
print(links) | ||
|
||
asyncio.run(main()) | ||
``` | ||
|
||
## Page Bytes | ||
|
||
Get the raw bytes of a page to store the files in a database. | ||
|
||
```python | ||
import asyncio | ||
from spider_rs import Page | ||
|
||
async def main(): | ||
page = Page("https://choosealicense.com") | ||
page.fetch() | ||
links = page.get_bytes() | ||
print(links) | ||
|
||
asyncio.run(main()) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters