我有一个类似于这样的html文件:
<html>
<head>
<css files>
<js files>
// maybe other things in header
</head>
<body>
// body contents ..
</body>
</html>
现在我想获得标题内容:
<css files>
<js files>
// maybe other things in header
怎么弄到这部分?
类似于:
string header = HTML
string html = "<table><tr><td>xyz</td><td>abc</td><td>mno</td></tr></table>"
HtmlDocument res = new HtmlDocument();
res.LoadHtml(html);
res.DocumentNode.SelectNodes("//table/tr/td[contains(translate(.,'ABCDEFGHIJKLMNOPQRSTUV
我的代码
res = requests.get(url='https://myself-bbs.com/thread-45431-1-1.html', headers=headers).text
html = BeautifulSoup(res, features='lxml')
for i in html.find_all('ul', class_='main_list'):
print(i)
结果
<ul class="main_list"><li>
<a href=