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

Syntax Error - Unexpected '>' #50

Open
flywire opened this issue Apr 2, 2021 · 1 comment
Open

Syntax Error - Unexpected '>' #50

flywire opened this issue Apr 2, 2021 · 1 comment
Labels

Comments

@flywire
Copy link

flywire commented Apr 2, 2021

Code in site works fine, seems to be a processing error:
_raise_syntax_error raise ECMASyntaxError(msg[len(tokens)].format(*tokens)) calmjs.parse.exceptions.ECMASyntaxError: Unexpected '>' at 47:133 between '=' at 47:132 and '{' at 47:135

Runs without processing code:

from bs4 import BeautifulSoup  
import requests
import re    
import js2xml    
from itertools import repeat    
from pprint import pprint as pp

url = "https://www.worldweatheronline.com/canberra-weather-averages/australian-capital-territory/au.aspx"
url = "https://www.investsmart.com.au/invest-with-us/investsmart-growth-portfolio"

soup = BeautifulSoup(requests.get(url).content, "html.parser")
script = soup.find("script", text=re.compile("Highcharts.Chart")).string
# parsed = js2xml.parse(script)

# print(js2xml.pretty_print(parsed))
print(script)

"""
data = [d.xpath(".//array/number/@value") for d in parsed.xpath("//property[@name='data']")]
categories = parsed.xpath("//property[@name='categories']//string/text()")
output =  list(zip(repeat(categories), data))    
print(pp(output))
"""

Error occurs:

from bs4 import BeautifulSoup  
import requests
import re    
import js2xml    
from itertools import repeat    
from pprint import pprint as pp

url = "https://www.worldweatheronline.com/canberra-weather-averages/australian-capital-territory/au.aspx"
url = "https://www.investsmart.com.au/invest-with-us/investsmart-growth-portfolio"

soup = BeautifulSoup(requests.get(url).content, "html.parser")
script = soup.find("script", text=re.compile("Highcharts.Chart")).string
parsed = js2xml.parse(script)

print(js2xml.pretty_print(parsed))
# print(script)
from bs4 import BeautifulSoup  
import requests
import re    
import js2xml    
from itertools import repeat    
from pprint import pprint as pp

url = "https://www.worldweatheronline.com/canberra-weather-averages/australian-capital-territory/au.aspx"
url = "https://www.investsmart.com.au/invest-with-us/investsmart-growth-portfolio"

soup = BeautifulSoup(requests.get(url).content, "html.parser")
script = soup.find("script", text=re.compile("Highcharts.Chart")).string
parsed = js2xml.parse(script)

print(js2xml.pretty_print(parsed))
# print(script)

data = [d.xpath(".//array/number/@value") for d in parsed.xpath("//property[@name='data']")]
categories = parsed.xpath("//property[@name='categories']//string/text()")
output =  list(zip(repeat(categories), data))    
print(pp(output))
@flywire
Copy link
Author

flywire commented Apr 2, 2021

js2xml uses calmjs library for parsing which is only meant for Node.js.
Node isn't meant to support let (and probably arrow functions too).

So maybe can't be supported.

@Gallaecio Gallaecio added the bug label Apr 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants