-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
73eca93
commit b7581f9
Showing
5 changed files
with
92 additions
and
18 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,27 @@ | ||
import os | ||
import boto3 | ||
from dotenv import load_dotenv | ||
from scrapy.spiders import Spider | ||
|
||
# Load environment variables from .env file | ||
load_dotenv() | ||
|
||
class Spider1(Spider): | ||
name = 'spider1' | ||
start_urls = ['https://www.softwareadvice.com/categories/'] | ||
|
||
def parse(self, response): | ||
# Extract the entire HTML content of the page | ||
page_content = response.text | ||
|
||
# Print the entire HTML content | ||
print(1, page_content) | ||
|
||
# Write the HTML content to S3 bucket | ||
s3 = boto3.client('s3', | ||
aws_access_key_id=os.getenv('AWS_ACCESS_KEY_ID'), | ||
aws_secret_access_key=os.getenv('AWS_SECRET_ACCESS_KEY'), | ||
region_name=os.getenv('AWS_REGION')) | ||
bucket_name = 'dinostomach' | ||
object_key = 'example.html' | ||
s3.put_object(Body=page_content, Bucket=bucket_name, Key=object_key) |
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,27 @@ | ||
import os | ||
import boto3 | ||
from dotenv import load_dotenv | ||
from scrapy.spiders import Spider | ||
|
||
# Load environment variables from .env file | ||
load_dotenv() | ||
|
||
class Spider2(Spider): | ||
name = 'spider2' | ||
start_urls = ['https://www.softwareadvice.com/categories/'] | ||
|
||
def parse(self, response): | ||
# Extract the entire HTML content of the page | ||
page_content = response.css('body').get() | ||
|
||
# Print the entire HTML content | ||
print(1, page_content) | ||
|
||
# Write the HTML content to S3 bucket | ||
s3 = boto3.client('s3', | ||
aws_access_key_id=os.getenv('AWS_ACCESS_KEY_ID'), | ||
aws_secret_access_key=os.getenv('AWS_SECRET_ACCESS_KEY'), | ||
region_name=os.getenv('AWS_REGION')) | ||
bucket_name = 'dinostomach' | ||
object_key = 'example1.html' | ||
s3.put_object(Body=page_content, Bucket=bucket_name, Key=object_key) |
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,7 @@ | ||
import requests | ||
|
||
url = "http://localhost:8000/scrape" | ||
|
||
response = requests.get(url) | ||
|
||
print(response.json()) |