Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
BeautifulSoup different behavior in Pythonista?
-
Can anyone help me to understand why this works in OS X but not in Pythonista?
https://gist.github.com/rmanly/7648823
For those who do not want to be bothered to click the link it is only 4 lines of code...7 with the imports. ;)
Also, on the interactive console in Pythonista why do things like 'soup.p', 'soup.a' etc. not work.
-
Weird. I think it may be a bug. ALSO: it's not fixed by Pythonista 1.4.
In the meantime, try this:
import requests import webbrowser import re page = requests.get('http://xkcd.com') comic = re.search("http://imgs.xkcd.com/comics/[^\.]*.png",page.text).group() webbrowser.open(comic)
You can even snag the alt text:
alt = re.search('src="http://imgs.xkcd.com/comics/[^\.]*.png"\s*title="([^"]*)"\s*alt=',page.text).groups()[0]
-
Hrmmm...
Thanks for the response.