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

Unable to parse page JSON content #25

Closed
afantastica688 opened this issue Apr 7, 2023 · 18 comments · Fixed by #27
Closed

Unable to parse page JSON content #25

afantastica688 opened this issue Apr 7, 2023 · 18 comments · Fixed by #27
Assignees

Comments

@afantastica688
Copy link

afantastica688 commented Apr 7, 2023

Hello.

I am encountering an error like this. What's the solution?
I need help urgently.
puppeteer version: 19.8.5

npm start

us-visa-appointment-notifier@1.0.0 start
node index.js

=====>>> Step: starting process with 250 tries left
=====>>> Step: logging in
=====>>> Step: checking for schedules

Unable to parse page JSON content
SyntaxError: Unexpected end of JSON input
at JSON.parse ()
at checkForSchedules (C:\Users\Alex92\Desktop\Visa\index.js:52:30)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async process (C:\Users\Alex92\Desktop\Visa\index.js:84:24)
at async C:\Users\Alex92\Desktop\Visa\index.js:99:5

@afantastica688 afantastica688 changed the title Starting the command Unable to parse page JSON content Apr 8, 2023
@afantastica688 afantastica688 reopened this Apr 8, 2023
@wassimwazzi
Copy link

wassimwazzi commented Apr 8, 2023

It looks like the page with the json of the dates has been removed on the US website, I am getting the same error.
We need to find where this page has been moved to.

@theoomoregbee
Copy link
Owner

I will be taking a look soon at this

@theoomoregbee theoomoregbee self-assigned this Apr 8, 2023
@afantastica688
Copy link
Author

afantastica688 commented Apr 8, 2023

I will be taking a look soon at this

I manually set the version information like this:

Windows x64:
node.js > 18.15.0
puppeteer > 19.8.5 (Because I am encountering an error while installing the 16.2.0 version embedded in the files "package.json".

I am getting a different error from the link below. When I do all the steps, I get the mailgun key error ("key" is required).
https://github.com/mueedqadri/US-visa-appointment-notifier

I get an error even though I typed the mailgun domain and the password starting with "key-".

Again I manually set the versions like this:
node.js > 18.15.0
puppeteer > 19.8.5

(I'm getting the same key error on version 16.2.0 of puppeteer.)

@edithal-14
Copy link

edithal-14 commented Apr 11, 2023

I am facing the same issue. Here is the stack trace

Unable to parse page JSON content <html><head></head><body></body></html>
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at checkForSchedules (/home/vigu/git/US-visa-appointment-notifier/index.js:53:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async process (/home/vigu/git/US-visa-appointment-notifier/index.js:85:24)
    at async process (/home/vigu/git/US-visa-appointment-notifier/index.js:92:3)
    at async /home/vigu/git/US-visa-appointment-notifier/index.js:100:5

@olivercoconuts
Copy link

olivercoconuts commented Apr 11, 2023

I am having the same issue. It'll be great if this can be resolved soon. Appreciate the work!

SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at checkForSchedules (C:\Users\olvr\US-visa-appointment-notifier\index.js:52:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async process (C:\Users\olvr\US-visa-appointment-notifier\index.js:84:24)
    at async process (C:\Users\olvr\US-visa-appointment-notifier\index.js:91:3)
    at async C:\Users\olvr\US-visa-appointment-notifier\index.js:99:5

@rupendersingh
Copy link

Has anyone found any solution ?

@fameka1
Copy link

fameka1 commented Apr 16, 2023

It looks like the page with the json of the dates has been removed on the US website, I am getting the same error. We need to find where this page has been moved to.
I looked at the site, the json link remains, but it does not work. So they did not put it in a new link. I needed this script urgently, but I could not find a solution.

@theoomoregbee
Copy link
Owner

I was able to replicate this with the help of a friend. I should be able to send a fix for this later this week.

@dezluan
Copy link

dezluan commented Apr 20, 2023

Excited for the fix @theoomoregbee !

@SumitMistry
Copy link

SumitMistry commented Apr 21, 2023

I get is this error now:


> root@ubuntu-22:~/US-visa# npm start
> us-visa-appointment-notifier@1.0.0 start
> node index.js
> 
> =====>>> Step: starting process with 1000 tries left
> =====>>> Step: logging in
> =====>>> Step: checking for schedules
> 
> Unable to parse page JSON content <html><head></head><body></body></html>
> SyntaxError: Unexpected end of JSON input
>     at JSON.parse (<anonymous>)
>     at checkForSchedules (/root/US-visa/index.js:52:30)
>     at processTicksAndRejections (internal/process/task_queues.js:97:5)
>     at async process (/root/US-visa/index.js:84:24)
>     at async /root/US-visa/index.js:98:7
> =====>>> Step: starting process with 999 tries left
> =====>>> Step: logging in
> =====>>> Step: checking for schedules
> 
> Unable to parse page JSON content <html><head></head><body></body></html>
> SyntaxError: Unexpected end of JSON input
>     at JSON.parse (<anonymous>)
>     at checkForSchedules (/root/US-visa/index.js:52:30)
>     at processTicksAndRejections (internal/process/task_queues.js:97:5)
>     at async process (/root/US-visa/index.js:84:24)
>     at async process (/root/US-visa/index.js:91:3)
>     at async /root/US-visa/index.js:98:7
> 
> ^Z
> [1]+  Stopped                 npm start
> root@ubuntu-22:~/US-visa# bg
> 
> [1]+ npm start &
> root@ubuntu-22:~/US-visa# =====>>> Step: starting process with 998 tries left
> 
> =====>>> Step: logging in
> =====>>> Step: checking for schedules
> 
> Unable to parse page JSON content <html><hea`

@dezluan
Copy link

dezluan commented Apr 21, 2023

@theoomoregbee Any chance a fix is imminent?

@ficusun
Copy link

ficusun commented Apr 22, 2023

@theoomoregbee you can fix it just add to checkForSchedules:

await page.setExtraHTTPHeaders({
    'Accept': 'application/json, text/javascript, */*; q=0.01',
    'X-Requested-With': 'XMLHttpRequest'
  });
  
  await page.goto(APPOINTMENTS_JSON_URL);

@edithal-14
Copy link

@theoomoregbee you can fix it just add to checkForSchedules:

await page.setExtraHTTPHeaders({
    'Accept': 'application/json, text/javascript, */*; q=0.01',
    'X-Requested-With': 'XMLHttpRequest'
  });
  
  await page.goto(APPOINTMENTS_JSON_URL);

Works like a charm!

@theoomoregbee
Copy link
Owner

@ficusun can you send a PR with this changes and I will approve and merge it in. Thanks.

@fameka1
Copy link

fameka1 commented Apr 22, 2023

@ficusun can you send a PR with this changes and I will approve and merge it in. Thanks.

Also, can you add two dates, eairliest date and latest date, to search for dates? For example, to send notifications between 2023-05-01 and 2023-07-01.

@ficusun
Copy link

ficusun commented Apr 23, 2023

@ficusun can you send a PR with this changes and I will approve and merge it in. Thanks.

Yes, I can, within a couple of days

@theoomoregbee
Copy link
Owner

already merged in. Thanks @ficusun for the suggestion.

@liuyang12
Copy link

@theoomoregbee you can fix it just add to checkForSchedules:

await page.setExtraHTTPHeaders({
    'Accept': 'application/json, text/javascript, */*; q=0.01',
    'X-Requested-With': 'XMLHttpRequest'
  });
  
  await page.goto(APPOINTMENTS_JSON_URL);

works like magic. thanks @ficusun! and it works for the python version as well. uxDaniel/visa_rescheduler#31 (comment)

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

Successfully merging a pull request may close this issue.