Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

你好,现在已经是用不了了,我改了改,本人python不太熟悉,小改了下 #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tjt852
Copy link

@tjt852 tjt852 commented May 13, 2017

No description provided.

Copy link
Owner

@justinyhuang justinyhuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your PR. This script has not been used/tested/maintained for a long time. I personally don't use it anymore. so please consider my review feedback and feel free to submit another change.

@@ -9,7 +10,7 @@ def add_new_line(obj):
if len(sys.argv) != 2:
print('usage: %s <word>' % sys.argv[0])
else:
word = re.sub(' ', '_', sys.argv[1]) #enable translate a sentence
word = quote(sys.argv[1]) #enable translate a sentence
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use urllib.quote and don't need to import quote from urllib.

result = dict[0].getText(' ') #only show the first match, which seems best
result = re.sub('&nbsp;', ' ', result) #replace the HTML space symbol
result = re.sub('[\s]{4,}', '\n', result) #remove redundent spaces
result = re.sub('\d+\. ', add_new_line, result) #highlight the groups
result = re.sub("\(function\(\)[\s\S]*",' ', result)
result = re.sub(u"一元好课[\s\S]*",' ', result)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try using a wilder pattern so that if the website changes again we don't need to change the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants