Note that there are some explanatory texts on larger screens.

plurals
  1. POCant get PHP to accept the POUND sign from a beautiful soup Python script
    primarykey
    data
    text
    <p>SO I have a script that pulls information from an event webpage. URL is this: <a href="http://everguide.com.au/melbourne/event/2012-jul-14/colour/" rel="nofollow">http://everguide.com.au/melbourne/event/2012-jul-14/colour/</a> </p> <p>This php script is calling a python script (its part of a for loop):</p> <pre><code>${"tmp" . $i} = utf8_encode (exec("python myscrape.py ${"eu" . $i}")); </code></pre> <p>It passes a URL. The python script is this:</p> <pre><code># -*- coding: utf-8 -*- import sys URL = sys.argv[1] #$URL = 'http://everguide.com.au/melbourne/event/2012-jul-14/colour/' import urllib2 req = urllib2.Request(URL) response = urllib2.urlopen(req) html = response.read() from BeautifulSoup import BeautifulSoup soup = BeautifulSoup(html.decode('utf-8')) soup.prettify() import re for node in soup.findAll(itemprop="name"): n = ''.join(node.findAll(text=True)) for node in soup.findAll(itemprop="url"): v = ''.join(node.findAll(text=True)) for node in soup.findAll("div", { "class" : "time" }): d = ''.join(node.findAll(text=True)) for node in soup.findAll("a", { "id" : "ctl00_holderBody_ctl00_lnkCat" }): c = ''.join(node.findAll(text=True)) vu = v vu.encode('utf-8', 'xmlcharrefreplace') re.escape(vu) print n,"|", d,"|", vu,"|", c </code></pre> <p>Which works really well, but only returns up to the or pipe before VU - it cant go past that!</p> <p>The UTF-8 encoding is set on all files, HTML and php.</p> <p>When there is a special character in the V variable, it breaks and stops. If there are no special characters, it works perfectly.</p> <p>Expected output is:</p> <pre><code>Colour | 14 July @ 7:30PM | 1000 £ Bend | Clubs &amp; Parties </code></pre> <p>This ouutput can be seen when running the script on the server (with same python command) but over PHP - i cant get the Venue string back in!</p> <p>Please help</p> <p>Rick</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload