Closed Tophattingson closed 1 year ago
Seconding this problem.
Thirding this problem! Cannot perform int() on a string with a comma character in it. We see the issue currently on the documented example of the Search class .update() method:
search = AO3.Search(any_field="Clarke Lexa", word_count=AO3.utils.Constraint(5000, 15000))
>>> search.update()
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
search.update()
File "C:\Users\nicol\AppData\Local\Programs\Python\Python39-32\lib\site-packages\AO3\threadable.py", line 13, in new
return func(*args, **kwargs)
File "C:\Users\nicol\AppData\Local\Programs\Python\Python39-32\lib\site-packages\AO3\search.py", line 112, in update
self.total_results = int(maindiv.find("h3", {"class": "heading"}).getText().strip().split(" ")[0])
ValueError: invalid literal for int() with base 10: '3,364'
I just cloned this repo (Hi! I'm new here hehe!) and think I found the fix for this issue. I'm a bit of a newb to GitHub, but I'll try creating a Pull Request for the fix. If I am unsuccessful and someone else finds this thread and it's still unresolved, the problem seems to be in this line of the Search class update() method:
self.total_results = int(maindiv.find("h3", {"class": "heading"}).getText().strip().split(" ")[0])
And it can be fixed with this:
self.total_results = int(maindiv.find("h3", {"class": "heading"}).getText().replace(',','').strip().split(" ")[0])
But I am in a country where the thousands delimiter is a comma. I'm not sure if this fix will work for areas where the thousands delimiter is a period. So this might be a better solution:
self.total_results = int(maindiv.find("h3", {"class": "heading"}).getText().replace(',','').replace('.','').strip().split(" ")[0])
I raised a pull request for this, I just don't know how to assign anyone to review and approve it. @ArmindoFlores many apologies for my newbness. [https://github.com/ArmindoFlores/ao3_api/pull/93]
Solution is to add .replace(',','') to self.total_results or equivalent