Skip to content Skip to sidebar Skip to footer

Requests : No Connection Adapters Were Found For, Error In Python3

import requests import xml.etree.ElementTree as ET import re gen_news_list=[] r_milligenel = requests.get('http://www.milliyet.com.tr/D/rss/rss/Rss_4.xml') root_milligenel = ET.fr

Solution 1:

If you add the line print(repr(item.text)) before the problematic line r = requests.get(item.text) you see that starting the second time item.text has \n at the beginning and the end which is not allowed for a URL.

'\nhttp://www.milliyet.com.tr/tbmm-baskani-cicek-programlarini/siyaset/detay/2037301/default.htm\n'

I use repr because it literally shows the newline as the string \n in its output.

The solution to your problem is to call strip on item.text to remove those newlines:

r = requests.get(item.text.strip())

Post a Comment for "Requests : No Connection Adapters Were Found For, Error In Python3"