Photo by Nicolas Picard on Unsplash

Python is really cool language and most important I love the web scraping concept of python. so basically web scraping can be referred to as gathering information from sources such as websites and using it for project

I have written a program that downloads a pdf from a specified link for example I have to use a dummy site that does not really exist to download a pdf

import socket

import requests

url= “http://xyz.com/sample.pdf"

res = requests.get(url)

print(res)

f = open(“sample.pdf”,”wb”)

f.write(res.content)

f.close()

In this example, it copies all content of the pdf file to a new file called smaple.pdf and stores it in the current directory.if pdf is not on site it will show error 404 i.e file not found

--

--