Posts

Showing posts with the label utf-8

Python and BeautifulSoup encoding issues

Python and BeautifulSoup encoding issues I'm writing a crawler with Python using BeautifulSoup, and everything was going swimmingly till I ran into this site: http://www.elnorte.ec/ I'm getting the contents with the requests library: r = requests.get('http://www.elnorte.ec/') content = r.content If I do a print of the content variable at that point, all the spanish special characters seem to be working fine. However, once I try to feed the content variable to BeautifulSoup it all gets messed up: soup = BeautifulSoup(content) print(soup) ... <a class="blogCalendarToday" href="/component/blog_calendar/?year=2011&amp;month=08&amp;day=27&amp;modid=203" title="1009 artículos en este día"> ... It's apparently garbling up all the spanish special characters (accents and whatnot). I've tried doing content.decode('utf-8'), content.decode('latin-1'), also tried messing around with the fromEncoding parameter...

Deserializing C++ string in WCF service using Json converter

Deserializing C++ string in WCF service using Json converter I am trying to communicate with C# wcf service which takes josn as an input where json contains image data, i wrote C# client where I am converting the object (InputData) which contains image as byte to json and sending it to server. Client side: InputData RequestData; //copied image data into RequestData obj String jsonRequest = (new JavaScriptSerializer()).Serialize(RequestData); //converting obj to json where : public class InputData { private byte RawImage = null; public byte FrontImage { get return this.FrontRawImage; set if (null != value) { FrontRawImage = value.ToArray(); } } } Server side: //deserialize and get the object InputData requestData = JsonConvert.DeserializeObject<InputData>(jsonData); I am able to do this with C# client but the problem is, I have to communicate this WCF service from C++ client where I am convertin...