It is a memorandum at the time of web scribing with python.
from bs4 import BeautifulSoup
import reuest
import os
"""Proxy support"""
os.environ["https_proxy"] = "http://xxx.xx.xx.xx:8080"
url = "https://www.python.org/"
html = requests.get(url)
soup = BeautifulSoup(html.text, "lxml")
print(soup)
print("----------------------------------------------")
# python.If you want to get only the strings in org
name = soup.find_all("div", class_="introduction")
# name = soup.find_all("div", {"class": "introduction"}May be described as.
name = name[0].text
print(name)
title = soup.find_all("title")
title = title[0].text
print(title)
result
Python is a programming language that lets you work quickly and integrate systems more effectively. Learn More
Welcome to Python.org
Recommended Posts