Skip to content

Commit

Permalink
handle parsing of urls when passed as article title
Browse files Browse the repository at this point in the history
  • Loading branch information
bcicen committed Aug 26, 2021
1 parent b5ab2b7 commit b4bcc56
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion wikitables/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def fetch_page(self, title, method='GET'):
'format': 'json',
'action': 'query',
'explaintext': '',
'titles': title,
'titles': _parse_title(title),
'rvprop': 'content',
}
req = self.request(method, self.base_url, params=params)
Expand All @@ -35,3 +35,7 @@ def fetch_page(self, title, method='GET'):
raise ArticleNotFound('no matching articles returned')

return pages[page_id]

def _parse_title(s):
# extract title from, potentially, a URL
return s.split('/')[-1].split('#')[0].split('?')[0]

0 comments on commit b4bcc56

Please sign in to comment.