我想从 html 表中提取特定元素,这是我当前的代码:
tabela = soup.find("div", {"class" : "productDatatable"})
>>> tabela
<div class="productDatatable">\n<div>\r\n Category:\r\n <span class="productDatatableValue">\n<a href="/en/market/mt5/utility">Utilities</a>\n</span>\n</div>\n<div title="Number of activations available for the buyers of this application. During the activation, software product is bound to the buyer's hardware, so that the copy of the application cannot work on another PC. The application should be re-activated and downloaded again in order to launch it on another computer. If the activation limit is exceeded, the buyer will have to purchase the product again.">\r\n Activations:\r\n <span class="productDatatableValue">\r\n 5\r\n </span>\n</div>\n<div style="padding:5px;"></div>\n<div>\r\n Author:\r\n <span class="productDatatableValue">\n<span style="display: inline-block; vertical-align: middle; margin-top: -2px;"><span class="icoVerified small" title="Verified User"></span></span>\n<span title="Konstantin Chernov"><a class="author" href="/en/users/konstantin83" title="Konstantin83">Konstantin Chernov</a></span>\n</span>\n</div>\n<div>\r\n Published:\r\n <span class="productDatatableValue">\r\n 16 January 2013\r\n </span>\n</div>\n<div>\r\n Current version:\r\n <span class="productDatatableValue">1.55</span>\n</div>\n<div>\r\n Updated:\r\n <span class="productDatatableValue">\r\n 23 March 2015\r\n </span>\n</div>\n</div>
我如何从这个 html 输出中提取类别名称。我试过这个,但不工作。
tabela.find_element_by_xpath("//*[contains(text(), 'Category')]").find("span", {"class" : "productDatatable"}).text
我如何从这个 html 中获取类别?我需要输出Utilities
慕运维8079593
四季花海
相关分类