is it correct in the call_api(url) function to replace " " with "+"?
In main.py, the function call_api. There is a statement: url = url.replace(' ', '+') I have tried the example URL in Demonstration 1 (Dm. 1). https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=gene&retmax=5&retmode=json&sort=relevance&term=LMP10. It seems correct(result is same as Demonstration 1)
Then if I add a
So I want to know why you want to replace " " with "+"? Thanks
URLs cannot contain spaces. URL encoding normally replaces a space with a plus (+) sign or with %20.
I know. But replacing spaces with "+" cannot give you the right answer in the E-utils APIs. Why not replace it with ""(empty) ?
That might cause parsing issues for the API? If you don't have spaces between words sometimes the service returns nothing.
Another option is to replace with %20. Ultimately you want to do a HTML decode / escape, which is standardized. I have a feeling Python has some functions for that. There are two "levels" of escaping, one which takes query parameters into account, and the other encodes those too.