<p>要在不使用regex的情况下获得相同的输出:</p>
<pre><code>html = """
<a href="http://www.abcde.com"> <img style="width:100%" src="/FileUploads/B/763846f.jpg" alt="search" title="search" /></a>
<a id="parts_img01" href="/Result?s=9&amp;type=%E4&amp;name=%E9"><h4 style=""><i class="fa f-c" aria-hidden="true"></i>apple</h4></a>
<a id="parts_img02" href="/Result?s=12&amp;type=%E4&amp;name=%E4"><h4 style=""><i class="fa f-c" aria-hidden="true"></i>banana</h4></a>
<a id="parts_img03" href="/Result?s=10&amp;type=%E4&amp;name=%E8"><h4 style=""><i class="fa f-c" aria-hidden="true"></i>cherry</h4></a>
<a id="parts_img07" href="/Result?s=14&amp;type=%E4&amp;name=%E8"><h4 style=""><i class="fa f-c" aria-hidden="true"></i>melon</h4></a>
"""
from bs4 import BeautifulSoup
soup = BeautifulSoup(html, "lxml")
for link in soup.select("[id^='parts_img']"):
print(link['href'])
</code></pre>
<p>结果:</p>
<pre><code>/Result?s=9&type=%E4&name=%E9
/Result?s=12&type=%E4&name=%E4
/Result?s=10&type=%E4&name=%E8
/Result?s=14&type=%E4&name=%E8
</code></pre>