-1

I have a project of web scraping . I want to get the name of something for searching as input and add it to the end of my url . i tried the code bellow but it didn't work, the input did not become a part of url

search = input()
url= 'https://www.digikala.com/search/?q='+search
3
  • Doesn't this work for you? Commented Oct 23, 2020 at 9:25
  • This should work, the only exceptions would most likely be the need of conversion of special characters to their Unicode, such as ' -> %27 Commented Oct 23, 2020 at 9:27
  • Can you please share the output i.e., print the URL string. If you are using Py 2.7 then you might need raw_input, else the code should work Commented Oct 23, 2020 at 9:33

2 Answers 2

1

Here f-strings were not introduced before python 3.7 so use .format instead then:

search = input()
url= 'https://www.digikala.com/search/?q={}'.format(search)
Sign up to request clarification or add additional context in comments.

Comments

1

This should work, try it:

search = input()
url= f'https://www.digikala.com/search/?q={search}'

This is called f-string formatting.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.