首页 > 解决方案 > 替换没有 python 外部库的代码

问题描述

由于此代码包含外部 python 库 lxml 但我需要更改代码以使其仅适用于 python 内部库 + 请求库。因为 Zapier 不支持外部库

    from lxml import html
    import requests 
    import lxml.html 

    # download & parse web page
    doc = requests.get('https://www.makeuseof.com/feed/')
    parser = lxml.html.fromstring(doc.content) 
    #find all image tags
    x = parser.xpath('//img')
    #get all image tags 
    la=[]
    for t in x:
        la.append((t.get("src")))
    #remove multiple tags
    for  cell in set(la):
        if cell is not None:
            print(cell)

PS 我听说 urlib 可以做到,但我没有这样的想法。上面的代码也只是从提要页面中找到图像

标签: pythonbuild-automationzapier

解决方案


推荐阅读