theoomoregbee / US-visa-appointment-notifier

This is just a script I put together to check and notify me via email (MailGun) when there's an earlier date before my initial appointment date. It doesn't handle rescheduling.
MIT License
104 stars 57 forks source link

Unable to parse page JSON content #25

Closed afantastica688 closed 1 year ago

afantastica688 commented 1 year ago

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

wassimwazzi commented 1 year ago

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 commented 1 year ago

I will be taking a look soon at this

afantastica688 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

Has anyone found any solution ?

fameka1 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

Excited for the fix @theoomoregbee !

SumitMistry commented 1 year ago

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 commented 1 year ago

@theoomoregbee Any chance a fix is imminent?

ficusun commented 1 year ago

@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 commented 1 year ago

@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 commented 1 year ago

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

fameka1 commented 1 year ago

@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 commented 1 year ago

@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 commented 1 year ago

already merged in. Thanks @ficusun for the suggestion.

liuyang12 commented 1 year ago

@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. https://github.com/uxDaniel/visa_rescheduler/issues/31#issue-1677087217