morrolinux / subito-it-searcher

searcher for subito.it
100 stars 36 forks source link

When a new product is found "TypeError: can only concatenate str (not "NoneType") to str" #11

Closed Metus88 closed 3 years ago

Metus88 commented 3 years ago

The script can not concatenate the price. This is the error:

New search added: RobotTagliaerbaLombardia
Adding result: Robot tagliaerba MI322 Viking - 100 € - Merone (CO)
Traceback (most recent call last):
  File "subito-searcher.py", line 188, in <module>
    run_query(args.url, args.name, False)
  File "subito-searcher.py", line 136, in run_query
    tmp = "New element found for "+name+": "+title+" @ "+price+" - "+location+" --> "+link+'\n'
TypeError: can only concatenate str (not "NoneType") to str

If in line 136 I edit the script deleting the price it works.

                tmp = "New element found for "+name+": "+title+"- "+location+" --> "+link+'\n'

So the problem is the price. I don't know ho to fix it.

More info: This is the product. maybe the problem is 100€ like 100&nbsp but not sure.

Thanks for help ----EDIT---- In the file searches.tracked there is. "price": null So I tried :

        try:
            price=product.find('p',class_=re.compile(r'price')).string #at the moment (18.3.2021) the price is under the 'p' tag
            if price == "null" : price = "PrezzoNullo"

But without succeed :-(