lxml.html. Error reading file; Failed to load external entity

后端 未结 1 664
轮回少年
轮回少年 2021-01-06 04:46

I am trying to get a movie trailer url from YouTube using parsing with lxml.html:

from lxml import html
import lxml.html
from lxml.etree import XPath

def ge         


        
相关标签:
1条回答
  • 2021-01-06 05:17

    SSL/TLS is not supported by libxml2. Use Python's urllib2 instead.

    If you try any url with http://<blah>.<blah> you wont have trouble but https is not supported here. There are redirection issues also.

    Try

    from urllib2 import urlopen
    import lxml.html
    tree = lxml.html.parse(urlopen('https://google.com'))
    

    For more information refer this


    Solution

    Well there are workaround. Try selenium and if you dont want a UI then run selenium in headless mode. Works fine i tried it myself.

    0 讨论(0)
提交回复
热议问题