-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestScraper.py
More file actions
33 lines (23 loc) · 992 Bytes
/
TestScraper.py
File metadata and controls
33 lines (23 loc) · 992 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from bs4 import BeautifulSoup
import requests
import csv
html_text = requests.get('https://www.techpowerup.com/gpu-specs/radeon-rx-7900-xtx.c3941').content
soup = BeautifulSoup(html_text, 'lxml')
name = soup.find('h1', class_='gpudb-name')
specs = soup.find_all('dl', class_='clearfix')
for spec in specs:
specText = spec.text.split()
file_path = 'Graphics Cards.csv'
if specText[0] == 'Memory' :
if len(specText) > 4 :
print(f'{specText[0]} {specText[1]}: {specText[2]} {specText[3]}')
print(f'Bandwidth: {specText[4]} {specText[5]}')
elif len(specText) == 4:
print(f'{specText[0]} {specText[1]}: {specText[2]} {specText[3]}')
else:
print(f'{specText[0]} {specText[1]}: {specText[2]}')
specText.insert(0, name.text)
with open(file_path, 'a', newline='') as csvfile:
csv_writer = csv.writer(csvfile)
csv_writer.writerows([specText])
print(specText)