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))
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:
Error occurs: