Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

created webscarping.py for html parsing#11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
cherukuri12 wants to merge2 commits intorealpython:master
base:master
Choose a base branch
Loading
fromcherukuri12:patch-1
Open
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletionsscripts/webscraping.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
import requests
from bs4 import BeautifulSoup

def cars_brand_links():
url = 'https://www.carsprite.com/en/car-prices/'
source_code = requests.get(url)
plain_text = source_code.text
soup = BeautifulSoup(plain_text)
for link in soup.findAll("a"):
href = "https://www.carsprite.com/en/" + link.get('href')
if "car-prices/" not in href:
pass
else:
data = href
get_single_item_data(data)
def get_single_item_data(brand_url):
source_code = requests.get(brand_url)
plain_text = source_code.text
soup = BeautifulSoup(plain_text)
for link in soup.findAll("a"):
href1 = link.get('href')
if "/en/" not in href1:
data1 = href1
if "https" not in data1:
data2 = data1
if "/car-prices/" not in data2:
data_final = 'https://www.carsprite.com/en/car-prices/' + data2
print(data_final)

else:
pass


cars_brand_links()

[8]ページ先頭

©2009-2025 Movatter.jp