File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 3
3
from itertools import chain
4
4
from pprint import pprint
5
5
6
+ import urllib .parse
7
+
6
8
from django .conf import settings
7
9
8
10
import requests
@@ -56,7 +58,11 @@ def __init__(self, soup):
56
58
57
59
def __getitem__ (self , key ):
58
60
if key == "image" :
59
- return self .soup .image .url .text if hasattr (self .soup , "image" ) else None
61
+ return (
62
+ self .soup .image .url .text
63
+ if hasattr (self .soup , "image" ) and self .soup .image
64
+ else None
65
+ )
60
66
return get_content (self .soup , key )
61
67
62
68
@property
@@ -156,9 +162,10 @@ def discover_feed(url) -> (str, str):
156
162
soup = BeautifulSoup (response .text , "html.parser" )
157
163
head = PageHead (soup )
158
164
if head .rss :
159
- feed_url = head .rss
165
+ feed_url = urllib .parse .urljoin (url , head .rss )
166
+ print (feed_url )
160
167
response = requests .get (
161
- head . rss , headers = {"User-Agent" : USER_AGENT }, timeout = TIMEOUT
168
+ feed_url , headers = {"User-Agent" : USER_AGENT }, timeout = TIMEOUT
162
169
)
163
170
else :
164
171
raise ValueError ("No feed found in HTML" )
You can’t perform that action at this time.
0 commit comments