May-18-2018, 08:38 AM
from lxml import html import requests response = requests.get('https://catalog.data.gov/dataset#sec-organization_type') doc = html.fromstring(response.text) link = doc.cssselect('div.new-results') print(link[0].text_content().strip())
or using BeautifulSoup and lxml as parser
import requests from bs4 import BeautifulSoup response = requests.get('https://catalog.data.gov/dataset#sec-organization_type') soup = BeautifulSoup(response.text, 'lxml') div = soup.find('div', {'class':'new-results'}) print(div.text.strip())or
import requests from bs4 import BeautifulSoup response = requests.get('https://catalog.data.gov/dataset#sec-organization_type') soup = BeautifulSoup(response.text, 'lxml') div = soup.select('div.new-results') print(div[0].text.strip())
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs