小编Tec*_*c27的帖子

如何使用python从url中提取元描述?

我想从以下网站中提取标题和说明:

view-source:http://www.virginaustralia.com/au/en/bookings/flights/make-a-booking/

使用以下代码片段:

<title>Book a Virgin Australia Flight | Virgin Australia
</title>
    <meta name="keywords" content="" />
        <meta name="description" content="Search for and book Virgin Australia and partner flights to Australian and international destinations." />
Run Code Online (Sandbox Code Playgroud)

我想要标题和元内容.

我使用鹅但是它没有很好地提取.这是我的代码:

website_title = [g.extract(url).title for url in clean_url_data]
Run Code Online (Sandbox Code Playgroud)

website_meta_description=[g.extract(urlw).meta_description for urlw in clean_url_data] 
Run Code Online (Sandbox Code Playgroud)

结果是空的

python url extract meta-tags goose

7
推荐指数
1
解决办法
6702
查看次数

如何在 Python 中命名列表列表?

我有以下列表:

sims1 = [[(2, 0.90452874), (1, 0.83522302), (4, 0.77591574), (0, 0.72705799), (3, 0.52282226)],
         [(3, 0.79298556), (1, 0.78112978), (2, 0.76006395), (0, 0.58570701), (4, 0.40093967)],
         [(2, 0.9549554),  (1, 0.71705657), (0, 0.58731651), (3, 0.43987277), (4, 0.38266104)],
         [(2, 0.96805269), (4, 0.68034023), (1, 0.66391909), (0, 0.64251828), (3, 0.50730866)],
         [(2, 0.84748113), (4, 0.8338449),  (1, 0.61795002), (0, 0.60271078), (3, 0.20899911)]]
Run Code Online (Sandbox Code Playgroud)

我想根据这些字符串命名列表中的每个列表:url = ['a', 'b', 'c', 'd']. 例如,

>>> a
[(2, 0.90452874), (1, 0.83522302), (4, 0.77591574), (0, 0.72705799), (3, 0.52282226)]
>>> b 
[(3, 0.79298556), (1, 0.78112978), …
Run Code Online (Sandbox Code Playgroud)

python arrays list

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

python ×2

arrays ×1

extract ×1

goose ×1

list ×1

meta-tags ×1

url ×1