Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void listAppend(string [int] list, string entry)
- {
- int position = list.count();
- while (list contains position)
- position += 1;
- list[position] = entry;
- }
- boolean stringHasSuffix(string s, string suffix)
- {
- if (s.length() < suffix.length())
- return false;
- else if (s.length() == suffix.length())
- return (s == suffix);
- else if (substring(s, s.length() - suffix.length()) == suffix)
- return true;
- return false;
- }
- void parseNames(string s, string [int] names)
- {
- string [int][int] matches = s.group_string("<span class=\"i\">([^<]*)</span>");
- //print("matches = " + matches.to_json());
- foreach key in matches
- {
- string name = matches[key][1];
- if (name.length() >= 2 && name.stringHasSuffix(", "))
- name = name.substring(0, name.length() - 2);
- //print("name = \"" + name + "\"");
- names.listAppend(name);
- }
- }
- void main()
- {
- string page_text = visit_url("type69.php?date=2020-01-01", false);
- string [int] split = page_text.split_string("<p>");
- string [int] testing_item_names;
- string [int] testing_skill_names;
- string [int] testing_familiar_names;
- if (split.count() < 7)
- {
- print("split too low: " + split.count());
- return;
- }
- parseNames(split[2], testing_item_names);
- parseNames(split[4], testing_skill_names);
- parseNames(split[6], testing_familiar_names);
- print(testing_item_names.count() + " items seen.");
- print(testing_skill_names.count() + " skills seen.");
- print(testing_familiar_names.count() + " familiars seen.");
- foreach key in testing_item_names
- {
- string item_name = testing_item_names[key];
- item it = item_name.to_item();
- if (it != $item[none])
- continue;
- print("Unknown item name \"" + item_name + "\"");
- }
- foreach key in testing_skill_names
- {
- string name = testing_skill_names[key];
- skill s = name.to_skill();
- if (s != $skill[none])
- continue;
- print("Unknown skill name \"" + name + "\"");
- }
- foreach key in testing_familiar_names
- {
- string name = testing_familiar_names[key];
- familiar f = name.to_familiar();
- if (f != $familiar[none])
- continue;
- print("Unknown familiar name \"" + name + "\"");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement