Solved

Python Encoding Problem \u2013

Posted on 2016-09-08
4
85 Views
Last Modified: 2016-09-09
I am getting this error from a python script
 print(driver.page_source)
UnicodeEncodeError: 'ascii' codec can't encode character '\u2013' in position 424837: ordinal not in range(128)

Here is a part of the code
 html_source = driver.page_source
    print(driver.page_source)

Open in new window


I have opened a page using webdriver and I am trying to get the page source of that page.  Consequently, in debugging my script I wanted to see if the source code was being read in correctly.  Using the print() statement is when I realized the error.

I have 1000's of pages to read in like this and encountering the em dash will be frequent.  So what is the best way to handle this in the script so I don't have to start and stop the script all the time?
0
Comment
Question by:sharingsunshine
  • 2
  • 2
4 Comments
 
LVL 28

Accepted Solution

by:
pepr earned 500 total points
ID: 41791076
The problem is probably not with the page source. The problem is that print cannot convert the character for displaying. Wrap it using the ascii() function to convert the content to the ASCII representation of the string value:
print(ascii(driver.page_source))

Open in new window

0
 

Author Comment

by:sharingsunshine
ID: 41791140
that works but now the source is in gibberish

ts" /></button><button class="blogg-button blogg-menu-button blogg-collapse-left blogg-collapse-right" aria-haspopup="true" title="Go to page. The current value is 1." disabled="" tabindex="0"><span class="blogg-menu-button-content">1</span><span class="blogg-disclosureindicator"></span></button><button class="blogg-button blogg-collapse-left" title="Older posts" disabled="" tabindex="0"><img class="blogg-button-image" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAA0UlEQVQ4y2P4//8/A7Uxw6ih9DVUXFzcSkZGZqGcnBwP1QzV19ffoKen98za2nqJlpYWD1UMffPmTV9ubu4dHx+fZ25ubku0tbV5qBGmXG/fvu0rLS29ExAQQLTBxHiH6927dygGUyv2UQx2dnZeSJUkVVdXJxoREXHK29v7WVlZ2SmKDQUmLR55efkloJRQXV19ByjWSZGhMAOBEfQM5P2PHz/2UZr4sRnIRZGhwJwESvQkGUjQ0HXr1i0EJf4PHz4QbSAxYWoIjRSu0fKUaAwAoDvqK9Sz6rIAAAAASUVORK5CYII=" alt="Older posts" /></button></div> </div></div> <table __gwtcellbasedwidgetimpldispatchingfocus="true" __gwtcellbasedwidgetimpldispatchingblur="true" class="OMGM5KC-u-y bloggPostTable" cellspacing="0" style="table-layout: fixed;"><colgroup><col style="width: 40px;" /><col /><col style="width: 6em;" /><col style="width: 8em;" /><col style="width: 3em;" /><col style="width: 4em;" /><col style="width: 4em;" /><col style="width: 6em;" /></colgroup><thead aria-hidden="true" style="display: none;"></thead><tfoot aria-hidden="true" style="display: none;"></tfoot><tbody style="display: none;"></tbody><tbody><tr><td align="center" colspan="8"><div><div aria-hidden="true" style="width: 100%; height: 100%; padding: 0px; margin: 0px; display: none;"><div aria-hidden="true" style="width: 100%; height: 100%; display: none;"></div></div><div style="width: 100%; height: 100%; padding: 0px; margin: 0px;"><div class="OMGM5KC-u-q" style="width: 100%; height: 100%;"><img src="data:image/gif;base64,R0lGODlhIAAgAPYAAP///zZCSvr7+97g4eHj5Pz8/MjLzZqgpKKoq83Q0vf4+Ozt7qGmqpmfo7O4u+vs7I6UmXZ+hJyipunq6/T19ZedobW5vL/CxWBpcGNsc2hxd4mQlePk5fb29pacoLi8v/n5+dPW12VudIuRlu7v77K2uZSan8vO0Nvd3l5obmJrcb3Bw9HU1tbY2vHy8tze4FtlbMPHycrNz7q+wfLz9IyTl6iuseDh4+fp6p+lqERPVkJNVVJcY0FMU1pkaq+zt+bn6OTm5+/w8cDExrC1uKyxtIOKj6Wrrqqvsm11e3F6f3R9gmt0enB4fqessNja2253fWlyeNnb3c7R03N7ga2ytUpVXFVfZl1nbUdSWUVQWMbKzHyEiXiAhbe7vo+WmnuDiICHjISMkH6Gi3mBhlBbYk9ZYE1YX1dhZ9XX2dDT1IeOk8XIyoaNklhiabu/wkhTW4GJjkxWXZGXnJKZncLFyFNeZJ2jp2ZvdaSprT9KUgAAAAAAAAAAAAAAAAAAACH+GkNyZWF0ZWQgd2l0aCBhamF4bG9hZC5pbmZvACH5BAAFAAAAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAIAAgAAAH/4AAgoOEhYa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XbiAAOwAAAAAAAAAAAA==" width="32" height="32" class="gwt-Image" /></div></div></div></td></tr></tbody></table></div></div> </div> <div class="OMGM5KC-l-k"></div> </div></div> </div></div><div><script src="https://www.google.com/insights/consumersurveys/async_survey?site=uyzvo2o4zz5355ebo6ogwad6fe"></script></div><div class="OMGM5KC-m-a" tabindex="0"><button class="blogg-button blogg-primary"> Send feedback </button></div></div><div class="OMGM5KC-i-a" aria-hidden="true" style="display: none;"></div><div id="contain-402"></div><script src="//www.google.com/insights/consumersurveys/gk/prompt?t=a&amp;site=uyzvo2o4zz5355ebo6ogwad6fe&amp;random=1473420081929&amp;ref=https%3A%2F%2Fwww.blogger.com%2Fhome" gapi_processed="true"></script><iframe src="https://clients5.google.com/pagead/drt/dn/" aria-hidden="true" style="display: none;"></iframe></body></html>'

Open in new window


Here is the same page via copy and paste
<br />
<a href="http://www.theherbsplace.com/onsale" rel="nofollow" target="_blank"><img alt="http://www.theherbsplace.com/onsale" src="http://image.exct.net/lib/ff2c1c757166/i/7/58f9627e-a.jpg" style="border-width: 0px; display: block; height: auto; max-width: 600px; width: 100%;" /></a>
                    <br />
<table align="center" border="0" cellpadding="0" cellspacing="0" style="border-spacing: 0; color: #6e6f74; font-family: Arial, Helvetica, sans-serif; font-size: 14px; max-width: 560px; width: 100%px;">
                            <tbody>
<tr>
           <td style="color: #6e6f74; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0;"><table border="0" cellpadding="0" cellspacing="0" style="border-spacing: 0; color: #6e6f74; font-family: Arial, Helvetica, sans-serif; font-size: 14px; width: 100%px;">
                                        <tbody>
<tr>
                                            <td style="color: #6e6f74; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0;" valign="top"><table border="0" cellpadding="0" cellspacing="0" style="border-spacing: 0; color: #6e6f74; font-family: Arial, Helvetica, sans-serif; font-size: 14px; width: 100%px;">
                                                    <tbody>
<tr>
                                                        <td style="color: #6e6f74; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0;" valign="top"><table border="0" cellpadding="0" cellspacing="0" style="border-spacing: 0; color: #6e6f74; font-family: Arial, Helvetica, sans-serif; font-size: 14px; width: 100%px;">
                                                                <tbody>
<tr>
                                                                    <td style="color: #6e6f74; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0;">This
 morning, Nature's Sunshine shared BIG news. Our best-selling, most 
popular supplement for immune-system support is now available in a 32 
fl. oz. bottle (stock no. 21488)! Now you can protect you and your 
family all season long with Nature's Sunshine's Silver Shield with 
patented Aqua Sol Technology.</td>
                                                                </tr>
<tr>
                                                                    <td style="color: #6e6f74; padding-bottom: 0; padding-left: 0; padding-right: 15px; padding-top: 15px;">Silver Shield with patented Aqua Sol Technology:</td>
                                                                </tr>
<tr>
                                                                    <td style="color: #6e6f74; font-size: 16px; padding-bottom: 0; padding-left: 0; padding-right: 5px; padding-top: 15px;"><table align="center" border="0" cellpadding="2" cellspacing="0" style="border-spacing: 0; color: #6e6f74; font-family: Arial, Helvetica, sans-serif; font-size: 14px; width: 95%px;">
                                                                            <tbody>
<tr>
                                                                                <td style="color: #6e6f74; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0;" valign="top" width="9">•</td>
                                                                                <td style="color: #6e6f74; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0;">Offers safe and effective, broad-spectrum immune support, including antimicrobial support</td>
                                                                            </tr>
<tr>
                                                                                <td style="color: #6e6f74; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 5px;" valign="top" width="9">•</td>
                                                                                <td style="color: #6e6f74; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 5px;">Is composed of nano-size particles to ensure maximum bioavailability and potency</td>
                                                                            </tr>
<tr>
                                                                                <td style="color: #6e6f74; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 5px;" valign="top" width="9">•</td>
                                                                                <td style="color: #6e6f74; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 5px;">Provides 20 ppm of pure silver (100 mcg per serving)</td>
                                                                            </tr>
</tbody></table>
</td>
                                                                </tr>
<tr>
                                                                    <td style="color: #6e6f74; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 15px;">And now it's an even better value! Get more silver for your money with our 32 fl. oz. size!  </td>
                                                                </tr>
<tr>
                                                                    <td style="color: #6e6f74; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 15px;"><b>Shop today for amazing introductory offers! Save up to 18% through September 12.</b></td>
                                                                </tr>
</tbody></table>
</td>
                                                    </tr>
</tbody></table>
</td>
                                        </tr>
<tr>
                                          <td style="color: #6e6f74; padding-bottom: 30px; padding-left: 0; padding-right: 0; padding-top: 30px;"><center>
                                              <table cellpadding="0" cellspacing="0" style="border-spacing: 0; color: #6e6f74; font-family: Arial, Helvetica, sans-serif; font-size: 14px;">
                                                  <tbody>
<tr>
                                                      <td class="tpadding" style="color: #6e6f74; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0;"><table align="center" class="btnwidth100" style="border-spacing: 0; color: #6e6f74; font-family: Arial, Helvetica, sans-serif; font-size: 14px;">
                                                              <tbody>
<tr>
                                                                  
<td align="center" bgcolor="#006cb7" class="buttonCell btnHeightCell btnwidth100" height="22" style="-moz-border-radius: 4px; -webkit-border-radius: 4px; background-attachment: scroll; background-color: #006cb7; background-image: none; background-position: top left; background-repeat: repeat; border-bottom-color: #00406E; border-bottom-style: solid; border-bottom-width: 2px; border-left-color: #006cb7; border-left-style: solid; border-left-width: 2px; border-radius: 4px; border-right-color: #006cb7; border-right-style: solid; border-right-width: 2px; border-top-color: #006cb7; border-top-style: solid; border-top-width: 2px; color: white; display: block; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0;" width="170"><a class="buttonLink btnHeightLink" height="33px" href="http://www.theherbsplace.com/onsale" rel="nofollow" style="color: white; display: inline-block; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 22px; text-align: center; text-decoration: none; width: 100%;" target="_blank"><span style="color: white;"><b>ORDER NOW!</b></span></a>
                                                                  </td>
                                                              </tr>
</tbody></table>
</td>
                                                  </tr>
</tbody></table>
</center>
</td>
                                      </tr>
</tbody></table>
</td>
          </tr>
<tr>
                             <td style="color: #6e6f74; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0;"><table border="0" cellpadding="0" cellspacing="0" style="border-spacing: 0; color: #6e6f74; font-family: Arial, Helvetica, sans-serif; font-size: 14px; width: 100%px;">
                                        <tbody>
<tr>
                                            <td style="border-color: #d5d5d5; border-style: dashed; border-width: 2px; color: #6e6f74; padding-bottom: 20px; padding-left: 20px; padding-right: 20px; padding-top: 20px;">If you missed our LIVE webinar launch this morning, <a href="http://cl.exct.net/?qs=65cfe728e54d9cb79dc95e82cd008b937bc9830aa45e1e9b6fb5abcce0b24e39" style="color: #5583c7;" target="_blank">tune in tonight</a>
 for another LIVE presentation by Regional Manager and Silver Shield 
expert Laurence Smith (3:00 and 7:30 MDT). Find out all the amazing 
things Silver Shield can do for you and your group members.</td>
                                        </tr>
</tbody></table>
</td>
                            </tr>
</tbody></table>
<center>
                            
                     <table border="0" cellpadding="0" cellspacing="0" style="border-spacing: 0; color: #6e6f74; font-family: &quot;arial&quot; , &quot;helvetica&quot; , sans-serif; font-size: 14px;">
                                    <tbody>
<tr>
                                        <td style="color: #6e6f74; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0;"><a href="http://www.facebook.com/theherbsplace" style="color: #5583c7;" target="_blank"><img alt="Facebook" src="http://image.exct.net/lib/ff2c1c757166/i/6/b753e2d0-f.jpg" style="border-width: 0; display: block;" /></a></td>
                                        <td height="30" style="color: #6e6f74; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0;" width="7"></td>
                                        <td style="color: #6e6f74; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0;"><a href="http://www.twitter.com/theherbsplace" style="color: #5583c7;" target="_blank"><img alt="Twitter" src="http://image.exct.net/lib/ff2c1c757166/i/6/45dae22f-9.jpg" style="border-width: 0; display: block;" /></a></td>
                                        <td height="30" style="color: #6e6f74; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0;" width="7"></td>
                                        <td style="color: #6e6f74; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0;"><a href="http://www.pinterest.com/theherbsplace" style="color: #5583c7;" target="_blank"><img alt="Pinterest" src="http://image.exct.net/lib/ff2c1c757166/i/6/4d2d6570-2.jpg" style="border-width: 0; display: block;" /></a></td>
                                       
                                       
                                        </tr>
</tbody></table>
</center>
<table style="border-spacing: 0; color: #6e6f74; font-family: Arial, Helvetica, sans-serif; font-size: 14px; width: 100%px;">
                            <tbody>
<tr>
                                <td class="footerNoReply" style="color: #6e6f74; font-size: 10px; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0; text-align: center;"><br /></td></tr>
</tbody></table>
<a href="http://www.theherbsplace.com/Silver_Shield_Aqua_Sol_Technology_Colloidal_Silver_18_ppm_p_730.html" rel="nofollow" target="_blank"><b><br />Buy Silver Shield at wholesale prices every day</b></a>!
<br />
<br />
<div style="font-weight: bold; margin-bottom: 12px; text-align: left;">
<a href="http://www.theherbsplace.com/" imageanchor="1" rel="nofollow" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://1.bp.blogspot.com/-XsXBsKXDZ34/UNscoQTM32I/AAAAAAAAHIY/nPqDNGVlU2M/s1600/test_half_THP+Gingerbread+Logo.jpg" /><b></b></a>Sponsored by&nbsp;<a href="http://www.theherbsplace.com/" rel="nofollow"><b>The Herbs Place</b></a> - Wholesale Prices Always</div>
<div style="margin-bottom: 18px;">
<b><a href="http://www.theherbsplace.com/onsale.html" rel="nofollow" style="text-align: -webkit-auto;">What's on Sale Now?</a><span style="text-align: -webkit-auto;">&nbsp;*&nbsp;</span><a href="http://www.theherbsplace.com/forwomen.html" rel="nofollow" style="text-align: -webkit-auto;">Women</a><span style="text-align: -webkit-auto;">&nbsp;*&nbsp;</span><a href="http://www.theherbsplace.com/formen.html" rel="nofollow" style="text-align: -webkit-auto;">Men</a><span style="text-align: -webkit-auto;">&nbsp;*&nbsp;</span><a href="http://www.theherbsplace.com/children.html" rel="nofollow" style="text-align: -webkit-auto;">Children</a><span style="text-align: -webkit-auto;">&nbsp;*&nbsp;</span><a href="http://www.theherbsplace.com/essential.html" rel="nofollow" style="text-align: -webkit-auto;">Essential Oils</a><span style="text-align: -webkit-auto;">&nbsp;*&nbsp;</span><a href="http://www.theherbsplace.com/cleansing.html" rel="nofollow" style="text-align: -webkit-auto;">Cleansing</a><span style="text-align: -webkit-auto;">&nbsp;*&nbsp;</span><a href="http://www.theherbsplace.com/weightloss.html" rel="nofollow" style="text-align: -webkit-auto;">Weight Loss</a><span style="text-align: -webkit-auto;">&nbsp;*&nbsp;</span><a href="http://www.theherbsplace.com/Heartworm_sp_36.html" rel="nofollow" style="text-align: -webkit-auto;">Pets - Heartworms</a><span style="text-align: -webkit-auto;">&nbsp;*&nbsp;</span><a href="http://www.theherbsplace.com/Mood_Support_page_1_c_130.html" rel="nofollow" style="text-align: -webkit-auto;" target="_blank">Mood Support</a><span style="text-align: -webkit-auto;">&nbsp;*&nbsp;</span><a href="http://www.theherbsplace.com/Multi_Vitamin_page_1_c_115.html" rel="nofollow" style="text-align: -webkit-auto;">Multi-Vitamins</a><span style="text-align: -webkit-auto;">&nbsp;*&nbsp;</span><span style="text-align: -webkit-auto;"><a href="http://www.theherbsplace.com/pdf/brochure_website_2011.pdf" rel="nofollow">Most Popular Products Brochure</a></span></b></div>

Open in new window


I need the source so I can parse it with some regexes to change the links.
0
 
LVL 28

Expert Comment

by:pepr
ID: 41791195
The gibberish one is a different portion of the text -- it is for some encoded form of an image.

You still have the driver.page_source as a original Unicode string. The ascii() is only used for converting the content to the one that can be displayed via print. The print command has to determine the encoding that is used by the console that shows the result of printing. If the console uses some encoding that is not Unicode, the print encodes the Unicode string to that encoding. If it is not possible (the console is not capable to display everything), the exception is raised -- the one that you have observed.

Instead of printing, you can write your driver.page_source into a file and check its content using some Unicode-capable editor:
with open('check_me.txt', 'w', encoding='utf-8') as f:
    f.write(driver.page_source)

Open in new window

0
 

Author Closing Comment

by:sharingsunshine
ID: 41791896
You answered my question but upon looking deeper at the output I realized that I don't need the page source after all.  I just need the html of the page which I can get via a button on the blogger post page.

Thanks for your help and it's always a pleasure to have your input.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Sequence is something that used to store data in it in very simple words. Let us just create a list first. To create a list first of all we need to give a name to our list which I have taken as “COURSE” followed by equals sign and finally enclosed …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now