html - 从 soup 对象中提取包含所需字符串的行

标签 html python-3.x beautifulsoup

我有soup 。 我想提取包含这三个必需信息的所有行。

<str name="platformname">Sentinel-3</str>

<str name="filename">S3A_OL_2_LFR____20210429T160749_20210429T161049_20210429T180517_0180_071_154_2340_LN1_O_NR_002.SEN3</str> <str name="format">SAFE</str>

<link href="https://scihub.copernicus.eu/dhus/odata/v1/Products('c5d4a490-b546-4886-a9b9-983d7cc8f8d1')/$value"/>

我该怎么做?

soup = BeautifulSoup(html,features="lxml")
print (soup)



data3 = soup.find_all('href')
print (data3)

它打印[]

print (soup)下面给出。

<?xml version="1.0" encoding="utf-8"?><html><body><feed xmlns="http://www.w3.org/2005/Atom" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
<title>Sentinels Scientific Data Hub search results for: footprint:"Intersects(POLYGON ((-81.504409 37.739556, -81.504409 38.46053, -83.933278 38.46053, -83.933278 37.739556, -81.504409 37.739556)))"</title>
<subtitle>Displaying 450 to 459 of 40269 total results. Request done in 0.499 seconds.</subtitle>
<updated>2021-05-07T23:14:20.181Z</updated>
<author>
<name>Sentinels Scientific Data Hub</name>
</author>
<id>https://scihub.copernicus.eu/dhus/search?q=footprint:"Intersects(POLYGON ((-81.504409 37.739556, -81.504409 38.46053, -83.933278 38.46053, -83.933278 37.739556, -81.504409 37.739556)))"</id>
<opensearch:totalresults>40269</opensearch:totalresults>
<opensearch:startindex>450</opensearch:startindex>
<opensearch:itemsperpage>10</opensearch:itemsperpage>
<opensearch:query role="request" searchterms='footprint:"Intersects(POLYGON ((-81.504409 37.739556, -81.504409 38.46053, -83.933278 38.46053, -83.933278 37.739556, -81.504409 37.739556)))"' startpage="1"></opensearch:query>
<link href='https://scihub.copernicus.eu/dhus/search?q=footprint:"Intersects(POLYGON ((-81.504409 37.739556, -81.504409 38.46053, -83.933278 38.46053, -83.933278 37.739556, -81.504409 37.739556)))"&amp;start=450&amp;rows=10' rel="self" type="application/xml"/>
<link href='https://scihub.copernicus.eu/dhus/search?q=footprint:"Intersects(POLYGON ((-81.504409 37.739556, -81.504409 38.46053, -83.933278 38.46053, -83.933278 37.739556, -81.504409 37.739556)))"&amp;start=0&amp;rows=10' rel="first" type="application/xml"/>
<link href='https://scihub.copernicus.eu/dhus/search?q=footprint:"Intersects(POLYGON ((-81.504409 37.739556, -81.504409 38.46053, -83.933278 38.46053, -83.933278 37.739556, -81.504409 37.739556)))"&amp;start=440&amp;rows=10' rel="previous" type="application/xml"/>
<link href='https://scihub.copernicus.eu/dhus/search?q=footprint:"Intersects(POLYGON ((-81.504409 37.739556, -81.504409 38.46053, -83.933278 38.46053, -83.933278 37.739556, -81.504409 37.739556)))"&amp;start=460&amp;rows=10' rel="next" type="application/xml"/>
<link href='https://scihub.copernicus.eu/dhus/search?q=footprint:"Intersects(POLYGON ((-81.504409 37.739556, -81.504409 38.46053, -83.933278 38.46053, -83.933278 37.739556, -81.504409 37.739556)))"&amp;start=40268&amp;rows=10' rel="last" type="application/xml"/>
<link href="opensearch_description.xml" rel="search" type="application/opensearchdescription+xml"/>
<entry>
<title>S3A_OL_1_EFR____20210429T160749_20210429T161049_20210429T180528_0180_071_154_2340_LN1_O_NR_002</title>
<link href="https://scihub.copernicus.eu/dhus/odata/v1/Products('a6326d88-17b8-4050-a7af-be5df005edf1')/$value"/>
<link href="https://scihub.copernicus.eu/dhus/odata/v1/Products('a6326d88-17b8-4050-a7af-be5df005edf1')/" rel="alternative"/>
<link href="https://scihub.copernicus.eu/dhus/odata/v1/Products('a6326d88-17b8-4050-a7af-be5df005edf1')/Products('Quicklook')/$value" rel="icon"/>
<id>a6326d88-17b8-4050-a7af-be5df005edf1</id>
<summary>Date: 2021-04-29T16:07:48.604Z, Instrument: OLCI, Satellite: Sentinel-3, Size: 684.43 MB</summary>
<ondemand>false</ondemand>
<date name="beginposition">2021-04-29T16:07:48.604Z</date>
<date name="endposition">2021-04-29T16:10:48.604Z</date>
<date name="creationdate">2021-04-29T18:05:28Z</date>
<date name="ingestiondate">2021-04-29T18:19:03.242Z</date>
<int name="relativeorbitnumber">154</int>
<int name="orbitnumber">27077</int>
<str name="ecmwf">FORECAST</str>
<str name="filename">S3A_OL_1_EFR____20210429T160749_20210429T161049_20210429T180528_0180_071_154_2340_LN1_O_NR_002.SEN3</str>
<str name="format">SAFE</str>
<str name="identifier">S3A_OL_1_EFR____20210429T160749_20210429T161049_20210429T180528_0180_071_154_2340_LN1_O_NR_002</str>
<str name="instrumentshortname">OLCI</str>
<str name="sensoroperationalmode">Earth Observation</str>
<str name="instrumentname">Ocean Land Colour Instrument</str>
<str name="mode">EO</str>
<str name="platformidentifier">2016-011A</str>
<str name="onlinequalitycheck">PASSED</str>
<str name="orbitdirection">descending</str>
<str name="pdualongtrackcoord">2340</str>
<str name="pduduration">180</str>
<str name="passnumber">54154</str>
<str name="passdirection">descending</str>
<str name="procfacilityname">Land OLCI Processing and Archiving Centre [LN1]</str>
<str name="procfacilityorg">European Space Agency</str>
<str name="processinglevel">1</str>
<str name="processingname">Data Processing</str>
<str name="productlevel">L1</str>
<str name="producttype">OL_1_EFR___</str>
<str name="relorbitdir">descending</str>
<str name="relpassnumber">308</str>
<str name="relpassdirection">descending</str>
<str name="platformname">Sentinel-3</str>
<str name="size">684.43 MB</str>
<str name="timeliness">Near Real Time</str>
<str name="gmlfootprint">&lt;gml:Polygon srsName="http://www.opengis.net/gml/srs/epsg.xml#4326" xmlns:gml="http://www.opengis.net/gml"&gt;
   &lt;gml:outerBoundaryIs&gt;
      &lt;gml:LinearRing&gt;
         &lt;gml:coordinates&gt;31.47,-97.6785 31.378,-96.9588 31.2825,-96.2406 31.1828,-95.5222 31.0798,-94.8106 30.9724,-94.0966 30.8613,-93.3856 30.7466,-92.678 30.6271,-91.9682 30.5042,-91.2626 30.3822,-90.5576 30.2512,-89.8533 30.1194,-89.1524 29.9788,-88.455 29.8372,-87.7579 29.6891,-87.0617 29.5412,-86.3676 29.3888,-85.6762 29.2329,-84.9875 29.0737,-84.3025 31.6986,-83.4807 34.3224,-82.6127 36.941,-81.6929 39.5512,-80.7125 39.7277,-81.4833 39.8995,-82.2604 40.0654,-83.0386 40.2259,-83.8251 40.3843,-84.612 40.5344,-85.4013 40.6824,-86.1952 40.8192,-86.9912 40.9535,-87.7916 41.0779,-88.6006 41.2004,-89.4041 41.318,-90.2162 41.4291,-91.0279 41.5347,-91.8428 41.6345,-92.6611 41.7282,-93.4781 41.8166,-94.3033 41.8987,-95.1262 41.9761,-95.9587 39.3504,-96.3792 36.7229,-96.8055 34.0948,-97.2388 31.47,-97.6785&lt;/gml:coordinates&gt;
      &lt;/gml:LinearRing&gt;
   &lt;/gml:outerBoundaryIs&gt;
&lt;/gml:Polygon&gt;</str>
<str name="footprint">MULTIPOLYGON (((-84.3025 29.0737, -83.4807 31.6986, -82.6127 34.3224, -81.6929 36.941, -80.7125 39.5512, -81.4833 39.7277, -82.2604 39.8995, -83.0386 40.0654, -83.8251 40.2259, -84.612 40.3843, -85.4013 40.5344, -86.1952 40.6824, -86.9912 40.8192, -87.7916 40.9535, -88.6006 41.0779, -89.4041 41.2004, -90.2162 41.318, -91.0279 41.4291, -91.8428 41.5347, -92.6611 41.6345, -93.4781 41.7282, -94.3033 41.8166, -95.1262 41.8987, -95.9587 41.9761, -96.3792 39.3504, -96.8055 36.7229, -97.2388 34.0948, -97.6785 31.47, -96.9588 31.378, -96.2406 31.2825, -95.5222 31.1828, -94.8106 31.0798, -94.0966 30.9724, -93.3856 30.8613, -92.678 30.7466, -91.9682 30.6271, -91.2626 30.5042, -90.5576 30.3822, -89.8533 30.2512, -89.1524 30.1194, -88.455 29.9788, -87.7579 29.8372, -87.0617 29.6891, -86.3676 29.5412, -85.6762 29.3888, -84.9875 29.2329, -84.3025 29.0737)))</str>
<str name="uuid">a6326d88-17b8-4050-a7af-be5df005edf1</str>
</entry>
<entry>
<title>S3B_SL_2_LST____20210429T152818_20210429T153118_20210429T174459_0179_052_011_2340_LN2_O_NR_004</title>
<link href="https://scihub.copernicus.eu/dhus/odata/v1/Products('c5d4a490-b546-4886-a9b9-983d7cc8f8d1')/$value"/>
<link href="https://scihub.copernicus.eu/dhus/odata/v1/Products('c5d4a490-b546-4886-a9b9-983d7cc8f8d1')/" rel="alternative"/>
<link href="https://scihub.copernicus.eu/dhus/odata/v1/Products('c5d4a490-b546-4886-a9b9-983d7cc8f8d1')/Products('Quicklook')/$value" rel="icon"/>
<id>c5d4a490-b546-4886-a9b9-983d7cc8f8d1</id>
<summary>Date: 2021-04-29T15:28:17.742Z, Instrument: SLSTR, Satellite: Sentinel-3, Size: 62.19 MB</summary>
<ondemand>false</ondemand>
<date name="beginposition">2021-04-29T15:28:17.742Z</date>
<date name="endposition">2021-04-29T15:31:17.742Z</date>
<date name="creationdate">2021-04-29T17:44:59Z</date>
<date name="ingestiondate">2021-04-29T18:12:26.797Z</date>
<int name="relativeorbitnumber">11</int>
<int name="orbitnumber">15683</int>
<str name="ecmwf">FORECAST</str>
<str name="filename">S3B_SL_2_LST____20210429T152818_20210429T153118_20210429T174459_0179_052_011_2340_LN2_O_NR_004.SEN3</str>
<str name="format">SAFE</str>
<str name="instrumentshortname">SLSTR</str>
<str name="sensoroperationalmode">Earth Observation</str>
<str name="instrumentname">Sea and Land Surface Temperature Radiometer</str>
<str name="mode">EO</str>
<str name="platformidentifier">2018-039A</str>
<str name="onlinequalitycheck">PASSED</str>
<str name="orbitdirection">descending</str>
<str name="pduduration">179</str>
<str name="passnumber">31366</str>
<str name="passdirection">descending</str>
<str name="procfacilityname">Land SLSTR and SYN Processing and Archiving Centre [LN2]</str>
<str name="procfacilityorg">European Space Agency</str>
<str name="processinglevel">2</str>
<str name="processingname">Data Processing</str>
<str name="productlevel">L2</str>
<str name="producttype">SL_2_LST___</str>
<str name="relorbitdir">descending</str>
<str name="relpassnumber">22</str>
<str name="relpassdirection">descending</str>
<str name="platformname">Sentinel-3</str>
<str name="size">62.19 MB</str>
<str name="timeliness">Near Real Time</str>
<str name="pdualongtrackcoord">2340</str>
<str name="identifier">S3B_SL_2_LST____20210429T152818_20210429T153118_20210429T174459_0179_052_011_2340_LN2_O_NR_004</str>
<str name="gmlfootprint">&lt;gml:Polygon srsName="http://www.opengis.net/gml/srs/epsg.xml#4326" xmlns:gml="http://www.opengis.net/gml"&gt;
   &lt;gml:outerBoundaryIs&gt;
      &lt;gml:LinearRing&gt;
         &lt;gml:coordinates&gt;31.4979,-88.0826 31.4319,-87.5515 31.3571,-87.0195 31.2973,-86.4948 31.2147,-85.9638 31.1452,-85.4361 31.074,-84.9077 30.9847,-84.3813 30.9118,-83.8599 30.8249,-83.3306 30.7424,-82.8155 30.6565,-82.2898 30.5668,-81.7649 30.4679,-81.2482 30.3811,-80.7231 30.2825,-80.2005 30.1867,-79.691 30.0841,-79.171 29.9812,-78.6573 29.8747,-78.138 29.7689,-77.6321 29.6587,-77.1154 29.5564,-76.6055 29.4428,-76.0917 29.327,-75.5821 29.2086,-75.0755 29.0958,-74.5745 28.9716,-74.0658 28.853,-73.5574 28.7287,-73.0585 28.6818,-72.8698 31.2633,-72.0083 33.8843,-71.0922 36.4979,-70.1182 39.0941,-69.0809 39.1055,-69.0883 39.162,-69.2988 39.293,-69.8644 39.436,-70.4282 39.5661,-70.9919 39.7002,-71.5643 39.8221,-72.14 39.9485,-72.7028 40.0724,-73.2824 40.1925,-73.8583 40.3111,-74.4446 40.4154,-75.0224 40.5283,-75.6119 40.6367,-76.1963 40.741,-76.7794 40.8448,-77.3719 40.9446,-77.9636 41.0374,-78.5509 41.1298,-79.1479 41.2197,-79.7495 41.2999,-80.3443 41.3858,-80.9431 41.4701,-81.5499 41.5449,-82.1418 41.6118,-82.7496 41.695,-83.3526 41.7577,-83.9575 41.8143,-84.5692 41.8843,-85.1829 41.937,-85.7863 41.9913,-86.3972 41.9825,-86.3986 39.3591,-86.8086 36.7254,-87.2277 34.0904,-87.6547 31.4979,-88.0826&lt;/gml:coordinates&gt;
      &lt;/gml:LinearRing&gt;
   &lt;/gml:outerBoundaryIs&gt;
&lt;/gml:Polygon&gt;</str>
<str name="footprint">MULTIPOLYGON (((-72.8698 28.6818, -72.0083 31.2633, -71.0922 33.8843, -70.1182 36.4979, -69.0809 39.0941, -69.0883 39.1055, -69.2988 39.162, -69.8644 39.293, -70.4282 39.436, -70.9919 39.5661, -71.5643 39.7002, -72.14 39.8221, -72.7028 39.9485, -73.2824 40.0724, -73.8583 40.1925, -74.4446 40.3111, -75.0224 40.4154, -75.6119 40.5283, -76.1963 40.6367, -76.7794 40.741, -77.3719 40.8448, -77.9636 40.9446, -78.5509 41.0374, -79.1479 41.1298, -79.7495 41.2197, -80.3443 41.2999, -80.9431 41.3858, -81.5499 41.4701, -82.1418 41.5449, -82.7496 41.6118, -83.3526 41.695, -83.9575 41.7577, -84.5692 41.8143, -85.1829 41.8843, -85.7863 41.937, -86.3972 41.9913, -86.3986 41.9825, -86.8086 39.3591, -87.2277 36.7254, -87.6547 34.0904, -88.0826 31.4979, -87.5515 31.4319, -87.0195 31.3571, -86.4948 31.2973, -85.9638 31.2147, -85.4361 31.1452, -84.9077 31.074, -84.3813 30.9847, -83.8599 30.9118, -83.3306 30.8249, -82.8155 30.7424, -82.2898 30.6565, -81.7649 30.5668, -81.2482 30.4679, -80.7231 30.3811, -80.2005 30.2825, -79.691 30.1867, -79.171 30.0841, -78.6573 29.9812, -78.138 29.8747, -77.6321 29.7689, -77.1154 29.6587, -76.6055 29.5564, -76.0917 29.4428, -75.5821 29.327, -75.0755 29.2086, -74.5745 29.0958, -74.0658 28.9716, -73.5574 28.853, -73.0585 28.7287, -72.8698 28.6818)))</str>
<str name="uuid">c5d4a490-b546-4886-a9b9-983d7cc8f8d1</str>
</entry>
<entry>
<title>S3A_OL_2_LFR____20210429T160749_20210429T161049_20210429T180517_0180_071_154_2340_LN1_O_NR_002</title>
<link href="https://scihub.copernicus.eu/dhus/odata/v1/Products('750336c1-f037-4d15-818d-da5c4a911326')/$value"/>
<link href="https://scihub.copernicus.eu/dhus/odata/v1/Products('750336c1-f037-4d15-818d-da5c4a911326')/" rel="alternative"/>
<link href="https://scihub.copernicus.eu/dhus/odata/v1/Products('750336c1-f037-4d15-818d-da5c4a911326')/Products('Quicklook')/$value" rel="icon"/>
<id>750336c1-f037-4d15-818d-da5c4a911326</id>
<summary>Date: 2021-04-29T16:07:48.604Z, Instrument: OLCI, Satellite: Sentinel-3, Size: 108.73 MB</summary>
<ondemand>false</ondemand>
<date name="beginposition">2021-04-29T16:07:48.604Z</date>
<date name="endposition">2021-04-29T16:10:48.604Z</date>
<date name="creationdate">2021-04-29T18:05:17Z</date>
<date name="ingestiondate">2021-04-29T18:12:11.267Z</date>
<int name="relativeorbitnumber">154</int>
<int name="orbitnumber">27077</int>
<double name="cloudcoverpercentage">79.0</double>
<str name="ecmwf">FORECAST</str>
<str name="filename">S3A_OL_2_LFR____20210429T160749_20210429T161049_20210429T180517_0180_071_154_2340_LN1_O_NR_002.SEN3</str>
<str name="format">SAFE</str>
<str name="identifier">S3A_OL_2_LFR____20210429T160749_20210429T161049_20210429T180517_0180_071_154_2340_LN1_O_NR_002</str>
<str name="instrumentshortname">OLCI</str>
<str name="sensoroperationalmode">Earth Observation</str>
<str name="instrumentname">Ocean Land Colour Instrument</str>
<str name="mode">EO</str>
<str name="platformidentifier">2016-011A</str>
<str name="onlinequalitycheck">PASSED</str>
<str name="orbitdirection">descending</str>
<str name="pdualongtrackcoord">2340</str>
<str name="pduduration">180</str>
<str name="passnumber">54154</str>
<str name="passdirection">descending</str>
<str name="procfacilityname">Land OLCI Processing and Archiving Centre [LN1]</str>
<str name="procfacilityorg">European Space Agency</str>
<str name="processinglevel">2</str>
<str name="processingname">Data Processing</str>
<str name="productlevel">L2</str>
<str name="producttype">OL_2_LFR___</str>
<str name="relorbitdir">descending</str>
<str name="relpassnumber">308</str>
<str name="relpassdirection">descending</str>
<str name="platformname">Sentinel-3</str>
<str name="size">108.73 MB</str>
<str name="timeliness">Near Real Time</str>
<str name="gmlfootprint">&lt;gml:Polygon srsName="http://www.opengis.net/gml/srs/epsg.xml#4326" xmlns:gml="http://www.opengis.net/gml"&gt;
   &lt;gml:outerBoundaryIs&gt;
      &lt;gml:LinearRing&gt;
         &lt;gml:coordinates&gt;31.47,-97.6785 31.378,-96.9588 31.2825,-96.2406 31.1828,-95.5222 31.0798,-94.8106 30.9724,-94.0966 30.8613,-93.3856 30.7466,-92.678 30.6271,-91.9682 30.5042,-91.2626 30.3822,-90.5576 30.2512,-89.8533 30.1194,-89.1524 29.9788,-88.455 29.8372,-87.7579 29.6891,-87.0617 29.5412,-86.3676 29.3888,-85.6762 29.2329,-84.9875 29.0737,-84.3025 31.6986,-83.4807 34.3224,-82.6127 36.941,-81.6929 39.5512,-80.7125 39.7277,-81.4833 39.8995,-82.2604 40.0654,-83.0386 40.2259,-83.8251 40.3843,-84.612 40.5344,-85.4013 40.6824,-86.1952 40.8192,-86.9912 40.9535,-87.7916 41.0779,-88.6006 41.2004,-89.4041 41.318,-90.2162 41.4291,-91.0279 41.5347,-91.8428 41.6345,-92.6611 41.7282,-93.4781 41.8166,-94.3033 41.8987,-95.1262 41.9761,-95.9587 39.3504,-96.3792 36.7229,-96.8055 34.0948,-97.2388 31.47,-97.6785&lt;/gml:coordinates&gt;
      &lt;/gml:LinearRing&gt;
   &lt;/gml:outerBoundaryIs&gt;
&lt;/gml:Polygon&gt;</str>
<str name="footprint">MULTIPOLYGON (((-84.3025 29.0737, -83.4807 31.6986, -82.6127 34.3224, -81.6929 36.941, -80.7125 39.5512, -81.4833 39.7277, -82.2604 39.8995, -83.0386 40.0654, -83.8251 40.2259, -84.612 40.3843, -85.4013 40.5344, -86.1952 40.6824, -86.9912 40.8192, -87.7916 40.9535, -88.6006 41.0779, -89.4041 41.2004, -90.2162 41.318, -91.0279 41.4291, -91.8428 41.5347, -92.6611 41.6345, -93.4781 41.7282, -94.3033 41.8166, -95.1262 41.8987, -95.9587 41.9761, -96.3792 39.3504, -96.8055 36.7229, -97.2388 34.0948, -97.6785 31.47, -96.9588 31.378, -96.2406 31.2825, -95.5222 31.1828, -94.8106 31.0798, -94.0966 30.9724, -93.3856 30.8613, -92.678 30.7466, -91.9682 30.6271, -91.2626 30.5042, -90.5576 30.3822, -89.8533 30.2512, -89.1524 30.1194, -88.455 29.9788, -87.7579 29.8372, -87.0617 29.6891, -86.3676 29.5412, -85.6762 29.3888, -84.9875 29.2329, -84.3025 29.0737)))</str>
<str name="uuid">750336c1-f037-4d15-818d-da5c4a911326</str>
</entry>
<entry>
<title>S3B_SL_1_RBT____20210429T152818_20210429T153118_20210429T174504_0179_052_011_2340_LN2_O_NR_004</title>
<link href="https://scihub.copernicus.eu/dhus/odata/v1/Products('54988bf2-b701-4e26-96d5-42097dace00e')/$value"/>
<link href="https://scihub.copernicus.eu/dhus/odata/v1/Products('54988bf2-b701-4e26-96d5-42097dace00e')/" rel="alternative"/>
<link href="https://scihub.copernicus.eu/dhus/odata/v1/Products('54988bf2-b701-4e26-96d5-42097dace00e')/Products('Quicklook')/$value" rel="icon"/>
<id>54988bf2-b701-4e26-96d5-42097dace00e</id>
<summary>Date: 2021-04-29T15:28:17.742Z, Instrument: SLSTR, Satellite: Sentinel-3, Size: 427.28 MB</summary>
<ondemand>false</ondemand>
<date name="beginposition">2021-04-29T15:28:17.742Z</date>
<date name="endposition">2021-04-29T15:31:17.742Z</date>
<date name="creationdate">2021-04-29T17:45:04Z</date>
<date name="ingestiondate">2021-04-29T18:06:53.303Z</date>
<int name="relativeorbitnumber">11</int>
<int name="orbitnumber">15683</int>
<str name="ecmwf">FORECAST</str>
<str name="filename">S3B_SL_1_RBT____20210429T152818_20210429T153118_20210429T174504_0179_052_011_2340_LN2_O_NR_004.SEN3</str>
<str name="format">SAFE</str>
<str name="instrumentshortname">SLSTR</str>
<str name="sensoroperationalmode">Earth Observation</str>
<str name="instrumentname">Sea and Land Surface Temperature Radiometer</str>
<str name="mode">EO</str>
<str name="platformidentifier">2018-039A</str>
<str name="onlinequalitycheck">PASSED</str>
<str name="orbitdirection">descending</str>
<str name="pduduration">179</str>
<str name="passnumber">31366</str>
<str name="passdirection">descending</str>
<str name="procfacilityname">Land SLSTR and SYN Processing and Archiving Centre [LN2]</str>
<str name="procfacilityorg">European Space Agency</str>
<str name="processinglevel">1</str>
<str name="processingname">Data Processing</str>
<str name="productlevel">L1</str>
<str name="producttype">SL_1_RBT___</str>
<str name="relorbitdir">descending</str>
<str name="relpassnumber">22</str>
<str name="relpassdirection">descending</str>
<str name="platformname">Sentinel-3</str>
<str name="size">427.28 MB</str>
<str name="timeliness">Near Real Time</str>
<str name="pdualongtrackcoord">2340</str>
<str name="identifier">S3B_SL_1_RBT____20210429T152818_20210429T153118_20210429T174504_0179_052_011_2340_LN2_O_NR_004</str>
<str name="gmlfootprint">&lt;gml:Polygon srsName="http://www.opengis.net/gml/srs/epsg.xml#4326" 

最佳答案

如果我理解正确的话,您想从每个 <entry> 获取全部 3 条信息( html 包含您的 XML 片段):

from bs4 import BeautifulSoup

soup = BeautifulSoup(html, "lxml")

for entry in soup.select("entry"):
    print(entry.select_one('str[name="platformname"]').text)
    print(entry.select_one('str[name="filename"]').text)
    print(entry.select_one("link:not([rel])")["href"])
    print("-" * 80)

打印:

Sentinel-3
S3A_OL_1_EFR____20210429T160749_20210429T161049_20210429T180528_0180_071_154_2340_LN1_O_NR_002.SEN3
https://scihub.copernicus.eu/dhus/odata/v1/Products('a6326d88-17b8-4050-a7af-be5df005edf1')/$value
--------------------------------------------------------------------------------
Sentinel-3
S3B_SL_2_LST____20210429T152818_20210429T153118_20210429T174459_0179_052_011_2340_LN2_O_NR_004.SEN3
https://scihub.copernicus.eu/dhus/odata/v1/Products('c5d4a490-b546-4886-a9b9-983d7cc8f8d1')/$value
--------------------------------------------------------------------------------
Sentinel-3
S3A_OL_2_LFR____20210429T160749_20210429T161049_20210429T180517_0180_071_154_2340_LN1_O_NR_002.SEN3
https://scihub.copernicus.eu/dhus/odata/v1/Products('750336c1-f037-4d15-818d-da5c4a911326')/$value
--------------------------------------------------------------------------------
Sentinel-3
S3B_SL_1_RBT____20210429T152818_20210429T153118_20210429T174504_0179_052_011_2340_LN2_O_NR_004.SEN3
https://scihub.copernicus.eu/dhus/odata/v1/Products('54988bf2-b701-4e26-96d5-42097dace00e')/$value
--------------------------------------------------------------------------------

关于html - 从 soup 对象中提取包含所需字符串的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67442717/

相关文章:

jquery - 如何在没有数据库或后端代码的情况下处理多语言网站?

python - 带有枚举和 for 循环的代码在第一个字母上给我重复的结果

python - 转置后如何转置合并相同的列名?

html - 媒体查询不适用于移动设备、元数据集

html - 使用 CSS 自动调整宽度内容

python - Beautifulsoup findAll,如何获取第二条文本

python - 从网页表格中抓取值

python - 如何将自定义解析器与 Python 的 Beautiful Soup 一起使用?

javascript - 如何使用 jQuery 和 data-rel 在链接元素中启动 CSS 效果?

python-3.x - 使用循环展开元组与不使用循环展开元组