Linear Optimization Engine Return 2nd Best Option Google Scripts

Linear optimization engine return 2nd best option google scripts

I found that the best way to parse html in google apps is to avoid using XmlService.parse or Xml.parse.

Linear optimization engine return 2nd best option google scripts

XmlService.parse doesn't work well with bad html code from certain websites.

Here a basic example on how you can parse any website easily without using XmlService.parse or Xml.parse.

In this example, i am retrieving a list of president from "wikipedia.org/wiki/President_of_the_United_States" whit a regular javascript document.getElementsByTagName(), and pasting the values into my google spreadsheet.

1- Create a new Google Sheet;

2- Click the menu Tools > Script editor... to open a new tab with the code editor window and copy the following code into your Code.gs:

3- Add an HTML file to your Apps Script project.

11 Google Sheets Automations - Examples, Scripts and Add Ons

Open the Script Editor and choose File > New > Html File, and name it 'test'.Then copy the following code into your test.html

4- Save your gs and html files and Go back to your spreadsheet. Reload your Spreadsheet.

Linear optimization engine return 2nd best option google scripts

Click on "Parse Menu" - "Parse". Then click on "Click here to get list" in the sidebar.

answered Jan 14 '17 at 17:12

Yves RYves R

10444 bronze badges

Linear optimization engine return 2nd best option google scripts