1

I am parsing a weblink and I want to save the whole webpage to a local file in format .html. I want to directly output soup to an html file locally for uploading a copy to S3-AWS ?

from bs4 import BeautifulSoup
import requests
url_name = "https://<weblink>/"
soup = BeautifulSoup(url_name,"html.parser")

Now, I am just wondering, like .txt can we output soup to .html as well. Suggestions appreciated.

Hari_pb
  • 7,088
  • 3
  • 45
  • 53
D-hash-pirit
  • 407
  • 2
  • 5
  • 12
  • 1
    Are you talking about doing something like [this](https://stackoverflow.com/questions/40529848/python-beautifulsoup-how-to-write-the-output-to-html-file)? –  Nov 23 '17 at 18:07

1 Answers1

-2

You imported requests but never actually used it. You need to GET the actual site

r=requests.get(url_name)

Then you can pass that to BS

soup=BeautifulSoup(r.text,'html.parser')
SuperStew
  • 2,857
  • 2
  • 15
  • 27
  • @yan `r.txt` is the response content, if that's what you mean. Anyway an html file is a text file basically, so all you have to do is save your file as .html – t.m.adam Nov 24 '17 at 06:12