GB
  
You are currently viewing the United Kingdom version of the site.
Would you like to switch to your local site?
9 MIN READ TIME

Scan and scrape websites using Python

David Bolton shows how to safely scrape the Linux Format archives in just 70 lines of Python without incurring our wrath!

OUR EXPERT

David Bolton once accidentally boosted the traffic for his firm’s website by 25% in one day by running a web scraper on it. Luckily, they never found out!

OUR EXPERT

David Bolton once accidentally boosted the traffic for his firm’s website by 25% in one day by running a web scraper on it. Luckily, they never found out!

Ever since the web made an appearance back in the mid-’90s, programmers have been writing software to extract data from web pages. It was quite a bit more difficult in those days, because much of the web was handwritten and inconsistent, plus graphics were used a lot then because CSS didn’t come along for a few years.

The browsers of the time (Netscape and Internet Explorer) were quite forgiving of mistakes, so you could find closing tags wrongly nested or even missing entirely. There was a lot of HTML that needed to be skipped over because it included font information, graphical images and other stuff. Nowadays, the HTML is a lot cleaner.

Web scrapings

A scraper is a program that pretends to be a web browser. When it runs, it fetches one or more HTML pages from a website and processes the pages to extract the desired information. This isn’t always easy, however, for the following reasons: 1. Accessing the data may be tricky – does it require logging in or handling cookies, or does it use POST instead of GET for parameters? (See boxout, below, for more on GET and POST.)

2. It’s someone else’s server, so you need to be gentle accessing it. This means you should definitely not run 20 threads all accessing the same server at the same time.

Unlock this article and much more with
You can enjoy:
Enjoy this edition in full
Instant access to 600+ titles
Thousands of back issues
No contract or commitment
Try for 99p
SUBSCRIBE NOW
30 day trial, then just £9.99 / month. Cancel anytime. New subscribers only.


Learn more
Pocketmags Plus
Pocketmags Plus

This article is from...


View Issues
Linux Format
December 2023
VIEW IN STORE

Other Articles in this Issue


Linux Format
Linux Format
Future Publishing Limited, Quay House, The Ambury, Bath, BA1
WELCOME
MEET THE TEAM
This issue we’re grappling with Podman to handle our services and make life easier, so what technology have you found that has made things simpler?
Docking apps…
Wasn’t technology supposed to make life easier? Sometimes
REGULARS AT A GLANCE
Newsdesk
THIS ISSUE: FOSS collaboration hit by embargo AI power use rockets KDE 6 arrives on desktops Linux boosts Cyberpunk 2077
Kernel Watch
Jon Masters keeps up with all the latest happenings in the Linux kernel, so you don’t have to.
Answers
Got a burning question about open source or the kernel? Whatever your level, email it to answers@linuxformat.com upgraded to v2.0; we’re still finding bugs…
Mailserver
Still very much supported: TurboPrint for Linux. CREDIT:
HotPicks
THE BEST NEW OPEN SOURCE SOFTWARE ON THE PLANET
REVIEWS
REVIEWS Addlink A93 4TB
Shane Downing is always cheap and usually pretty cheerful!
Intel Arc A580
Often rooting for the little guy, Jarred Walton wonders what Intel’s up to.
Tails 5.18
Shunting all his traffic through the darknet, we’re not sure whether this Nate Drake is real…
SpiralLinux 12.231008
Nate Drake gets his head in a spin over this customised version of Debian, which offers easy setup and proprietary firmware.
Pisi Linux 2.3.4
Nate Drake tastes this Turkish delight, marvelling at its originality and efficiency. Just don’t expect much help if you get stuck.
ROUNDUP
Raspberry Pi 5 killers
Industrial and professional single-board computer use can be a hairy business. Tam Hanna has seen it all, though, and guides you along.
MANAGE YOUR APPS!
MANAGE YOUR APPS!
David Rutland looks at dependency hell and the benefits of containers, and gets to grips with Podman, the newest container tool.
Pi USER
CoderDojo and Code Club become global hits
The help given to young coders is reaching around the world and everyone can get involved!
Dual-Fan Heatsink
During the hot summer months, Les Pounder’s poor Raspberry Pi Zero 2W was sweating in the heat. Can this case keep it cool?
Creality Ender 3 V3 SE
A low-cost, high-speed act has swept Denise Bertacchi off her feet!
RP2040 Matrix
Les Pounder dons his trench coat and shades, journeys into The RP2040 Matrix, then realises it’s the wrong matrix and he’s now in his mid-40s.
AnkerMake M5C
It seems Denise Bertacchi is in trouble as she’s misplaced her phone…
Create a Pi Pico USB camera trigger
Les Pounder’s drawers are full of old tech. No, he’s not smuggling technology, but he is reusing it in this project!
Control your own custom robotic arm
Matt Holder discovers how to take a standard model, apply some custom electronics and enable it all to be computer-controlled!
IN DEPTH
ENTROPY ISN’T WHAT IT USED TO BE
Nate Drake provides a brief history of randomness in Linux and how the kernel uses it to keep your data safe.
TUTORIALS
Get your life organised!
Shashank Sharma knows more CLI tools than he does people, and is always looking for more. It’s why he misses deadlines. But no more!
Master printing in Linux
Unlucky Nick Peers has to untangle a cornucopia of acronyms to reveal how to get his printer working at its best and in full colour!
Customise your home WordPress site
Michael Reed provides some words to the wise and explains how to add some content to your WordPress website and customise it.
Tweak and tune your own kernel scheduler
Mats Tage Axelsson explains how Linux keeps all its plates up in the air and when it can be helpful to intervene and stop it all crashing down.
Build the ultimate Amiga PC system
Les Pounder turns a lowly 2019 Intel Celeron-based laptop into a high-end Amiga machine – 1994 Les would be so envious!
ADMINISTERIA
Artificial intelligence rules of the road
AI is great, but caution is needed to make sure that it works as expected.
AI coded Bash scripts
Use ChatGPT to make your life easier by asking it the right questions.
CDNetworks CDN Pro
A powerful, programmable CDN with a strong China presence that pleases the notoriously hard-to-please Mike Williams.
Mozilla VPN
A standalone VPN from the people behind Firefox – Mike Williams wonders what’s not to like?
WordPress vs Wix
Running a website needn’t be a technical challenge. Nik Rawlinson compares the two leading platforms that can help anyone create and manage their own pages.
CODING ACADEMY
Process your smarthome sensor data
HOME ASSISTANT
ADVERTISEMENT
THE BRAIN TUMOUR CHARITY
thebraintumourcharity.org
Linux Format
www.techradar.com/pro/linux
Linux Format
techradar
techradar.com
code club
www.codeclub.org.uk
LINUX FORMAT
www.magazinesdirect.com/linux-format
NEW START
TOM'S HARDWARE
www.magazinesdirect.com
EFF
GO COMPARE
Chat
X
Pocketmags Support