Python 2 bytes character for URL

I struggled with 2bytes character python :-0 urllib2.quote(word.encode(‘UTF-8′))) might help for URL thing.

 

#-*- coding: utf-8 -*-

from bs4 import BeautifulSoup
import urllib2

temp = raw_input(“what do you want to search? :::”)
word = unicode(temp,’utf-8’)
try:
url =urllib2.urlopen(“http://m.endic.naver.com/search.nhn?searchOption=entryIdiom&query=”+ urllib2.quote(word.encode(‘UTF-8′)))
soup = BeautifulSoup(url,”html.parser”,from_encoding=’utf-8’)
target = soup.find_all(‘p’, attrs={‘class’:’desc’})

Advertisements

Author: SK,Seo

Me! Name: SK Seo

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s