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

Dog adoption category is not working #97

Open
michaelkuzmin opened this issue Jun 29, 2018 · 8 comments
Open

Dog adoption category is not working #97

michaelkuzmin opened this issue Jun 29, 2018 · 8 comments

Comments

@michaelkuzmin
Copy link

  1. I am trying to use an older version of KRH and I am getting this file (login password removed)
    PostalLat: '43.7559808' PostalLng: '-79.41077949999999' categoryId: '126' locationLevel0: 1700272 postAdForm.adType: OFFER postAdForm.addressCity: Toronto postAdForm.addressPostalCode: M2N5V7 postAdForm.addressProvince: 'ON' postAdForm.attributeMap[birthdate]: "July 1, 2017" postAdForm.attributeMap[petofferedby_s]: shelter postAdForm.city: Toronto postAdForm.description: "Hi, Im Cookie and I need a new home" postAdForm.geocodeLat: '43.7559808' postAdForm.geocodeLng: '-79.41077949999999' postAdForm.locationId: 1700273 postAdForm.postalCode: M2N5V7 postAdForm.priceType: GIVE_AWAY postAdForm.province: 'ON' postAdForm.title: Dog for adoption submitType: saveAndCheckout topAdDuration: '7' username: [email protected] password: 'psw123'

When I try to post I get an error

C:\Routine\kijijipy>python kijiji_repost_headless post C:\Routine\kijijipy\dogtest.yml
Image upload success on try #1
Traceback (most recent call last):
File "C:\Users\Michael\AppData\Local\conda\conda\envs\p36\lib\runpy.py", line 193, in run_module_as_main
"main", mod_spec)
File "C:\Users\Michael\AppData\Local\conda\conda\envs\p36\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "kijiji_repost_headless_main
.py", line 183, in
main()
File "kijiji_repost_headless_main
.py", line 50, in main
args.function(args)
File "kijiji_repost_headless_main_.py", line 91, in post_ad
api.post_ad_using_data(data, image_files)
File "kijiji_repost_headless\kijiji_api.py", line 201, in post_ad_using_data
raise KijijiApiException("Could not post ad.", resp.text)
File "kijiji_repost_headless\kijiji_api.py", line 24, in init
f.write(dump)
File "C:\Users\Michael\AppData\Local\conda\conda\envs\p36\lib\encodings\cp1251.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\xe7' in position 19966: character maps to

Then when I try to generate an yml using the most recent version I can't create a yml at all, it tells me that Google Maps API needs a API key. So I cut out the code completely but I am still getting the same issue. I also noticed that the actual form doe not have a give away option so I tried replacing the price with 1 dollar but the error is still the same.

Can someone please help me create a valid YML file for dog giveaway category? I can edit the values manually.

@jackm
Copy link
Contributor

jackm commented Jul 4, 2018

Could you post the Google Maps API error message?

@michaelkuzmin
Copy link
Author

@jackm can't replicate right now. Probably because currently, the number of API calls is under some threshold. Still, with the newest version the radio is not being handled correctly (it's asking me a question for every choice of the radio button and I can't put 0 because 0 restarts it) and even if I fix this manually in the YML file I still get the same error about \xe7 character.

@jackm
Copy link
Contributor

jackm commented Jul 5, 2018

The UnicodeEncodeError is actually not the real problem but rather another unrelated error (soon to be fixed with a PR #98 I just made).

The actual problem is where the KijijiApiException error is thrown with the message "Could not post ad.". This usually happens when Kijiji is expecting some extra fields for the ad that were not present, which is commonly found for any ads that aren't the usual buy&sell type.

In the mean time, you could manually implement the changes in PR #98 to fix the encoding problem, and then open the dump file in your browser to look at what errors the Kijiji site shows.

@michaelkuzmin
Copy link
Author

@jackm what about the part where the script handles the radio buttons incorrectly, asking a separate question for each bullet point? I'm not sure, maybe I am not fixing the YML file correctly. I tried to post in that category manually and look at what's being submitted, what I have in YML seems fine but I'm not totally sure...

@jackm
Copy link
Contributor

jackm commented Jul 5, 2018

That is likely an issue with how the kijiji_categories_attrs.json file is generated. Some of the categories are not grouped together properly which I believe is causing the issue.

The save_attribute_map_to_json.py script is outdated and is in need of a re-work.

@jackm
Copy link
Contributor

jackm commented Jul 7, 2018

For your particular case when posting an ad for the "Dogs & Puppies for Rehoming" category, you should add the following additional key to the yaml ad file.

  • Key name: postAdForm.attributeMap[petofferedby_s]
  • Set key value to one of shelter, regbreeder or owner

@michaelkuzmin
Copy link
Author

michaelkuzmin commented Jul 7, 2018

@jackm no, if you look at my original post in this thread I already had this, that was the first thing I did. but I did get this working. I don't know exactly how because I tried a number of things at once. I think it was probably terms and conditions checkbox
this works:

postAdForm.attributeMap[petofferedby_s]: shelter
postAdForm.attributeMap[birthdate_tdt]: 01/01/2017
postAdForm.adType: OFFER
postAdForm.priceType: FIXED
postAdForm.city: "Montr\xE9al"
postAdForm.province: QC
postAdForm.postalCode: H4A 3H1
postAdForm.addressCity: "Montr\xE9al"
postAdForm.addressProvince: QC
postAdForm.addressPostalCode: H4A 3H1
postAdForm.geocodeLat: '45.4718214'
postAdForm.geocodeLng: '-73.6050721'
postAdForm.locationId: 1700281
postingLocation: 1700281
PostalLat: ''
PostalLng: ''
locationLevel0: 80002
topAdDuration: '7'
submitType: saveAndCheckout
postAdForm.title: Dog needs home
postAdForm.description: "description here"
categoryId: '126'
postAdForm.priceAmount: '1'
image_paths: ['C:\Dog\1.jpg']
username: [email protected]
password: pass
postAdForm.confirmedTerms: true

how I fixed it is I did it manually and I looked at what Chrome was submitting to the server and I just made the YML file parameters sort of resemble that submittion

@jackm
Copy link
Contributor

jackm commented Jul 12, 2018

Yes you're right, I didn't see that you had that field in there before.

What you did by looking at the HTTP POST request for the parameter names is exactly what I end up doing when I have to post an ad that requires some additional unique parameters. The build_ad subcommand is supposed to make this process more automated, but it still doesn't yet cover all of the corner cases as you've seen.

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

No branches or pull requests

2 participants