What do you want to save?
Add Code snippet
New code examples
-
Other 2022-01-22 19:36:19
web scraping print all p and h2 tags
import requests from bs4 import BeautifulSoup url = 'https://www.python.org/' reqs = requests.get(url) soup = BeautifulSoup(reqs.text, 'lxml') print("List of all the h1, h2, h3 :") for heading in soup.find_all(["h1", "h2", &q... Add solution -
Python 2021-11-18 16:43:13
export html table to csv python
# Importing the required modules import os import sys import pandas as pd from bs4 import BeautifulSoup path = 'html.html' # empty list data = [] # for getting the header from # the HTML file list_header = [] soup = BeautifulSoup(op... Add solution -
Python 2021-11-06 20:08:24
iterate over meta tag python
import urllib.request from bs4 import BeautifulSoup f = open('out.txt','w') url = "http://www.international.gc.ca/about-a_propos/atip-aiprp/reports-rapports/2012/02-atip_aiprp.aspx" page = urllib.request.urlopen(url) soup = BeautifulSoup(page... Add solution -
Html 2021-11-04 04:02:16
python regex in html
>>> from bs4 import BeautifulSoup >>> soup = BeautifulSoup("<p>Some<b>bad<i>HTML") >>> print soup.prettify() <html> <body> <p> Some <b> bad <i> HTML import re print(soup.... Add solution -
Other 2021-10-24 01:56:16
grab a href using beuatiful soup
from BeautifulSoup import BeautifulSoup html = '''<a href="some_url">next</a> <span class="class"><a href="another_url">later</a></span>''' soup = BeautifulSoup(html) for a in soup.find_... Add solution -
Other 2021-10-23 02:30:09
Faster scraping
import requests from bs4 import BeautifulSoup BASE_URL = "https://news.ycombinator.com/" STORY_LINKS = [] for i in range(10): resp = requests.get(f"{BASE_URL}news?p={i}") soup = BeautifulSoup(resp.content, "html.parser&q... Add solution
Best helpers
Annu_tiger
+5
Webelo
+5
Des Wilson
+5
Twbrown
+5
Dreeves
+5
Xoxocrow
+5
Arash.amd
+5
Gaussler
+5
Bread
+5
Kenny W
+5
Chris Crook
+5
Xzhu
+5
Steven Choi
+5
KariEllen
+5
AndrewBC
+5
Static
+5
C. Starr
+5