我有一个带有多个 div的HTML 页面,例如:
<div class="post-info-wrap">
<h2 class="post-title"><a href="https://www.example.com/blog/111/this-is-1st-post/" title="Example of 1st post – Example 1 Post" rel="bookmark">sample post – example 1 post</a></h2>
<div class="post-meta clearfix">
<div class="post-info-wrap">
<h2 class="post-title"><a href="https://www.example.com/blog/111/this-is-2nd-post/" title="Example of 2nd post – Example 2 Post" rel="bookmark">sample post – example 2 post</a></h2>
<div class="post-meta clearfix">
Run Code Online (Sandbox Code Playgroud)
我需要使用类 post-info-wrap 获取所有 div 的值我是 BeautifulSoup 的新手
所以我需要这些网址:
等等...
我试过了:
import re
import requests
from bs4 import BeautifulSoup
r = requests.get("https://www.example.com/blog/author/abc")
data = r.content # Content of response
soup …Run Code Online (Sandbox Code Playgroud)