2017-07-23 19:56:51 +02:00
|
|
|
{% extends "main.html" %}
|
2017-09-07 13:40:42 +02:00
|
|
|
{% block title %}Scrape{% endblock %}
|
2017-07-23 19:56:51 +02:00
|
|
|
|
|
|
|
{% block content %}
|
|
|
|
<div class="container">
|
2017-09-07 13:40:42 +02:00
|
|
|
<h1>Scrape a page</h1>
|
2017-07-23 19:56:51 +02:00
|
|
|
|
2019-06-27 17:47:21 +02:00
|
|
|
<form role="form" action="scrape" method=post>
|
|
|
|
<div class="form-group row">
|
|
|
|
<label for="url" class="col-sm-2 col-form-label">URL:</label>
|
|
|
|
<div class="col-sm-10">
|
|
|
|
<input type="text" class="form-control" name="url" id=url placeholder="URL to scrape">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group row">
|
|
|
|
<label for="depth" class="col-sm-2 col-form-label">Link Depth:</label>
|
|
|
|
<div class="col-sm-2">
|
|
|
|
<select class="form-control" name="depth" id=depth>
|
2017-10-10 11:16:16 +02:00
|
|
|
<option value="1">1</option>
|
|
|
|
<option value="2">2</option>
|
|
|
|
<option value="3">3</option>
|
|
|
|
<option value="4">4</option>
|
|
|
|
<option value="5">5</option>
|
|
|
|
<option value="6">6</option>
|
|
|
|
<option value="7">7</option>
|
|
|
|
<option value="8">8</option>
|
|
|
|
<option value="9">9</option>
|
2019-06-27 17:47:21 +02:00
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group row">
|
|
|
|
<div class="col-sm-10">
|
|
|
|
<div class="form-check">
|
|
|
|
<input class="form-check-input"type="checkbox" name="listing" checked="true"></input>
|
|
|
|
<label for="listing" class="form-check-label">Display on main page</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
2017-07-23 19:56:51 +02:00
|
|
|
</div>
|
2019-06-27 17:47:21 +02:00
|
|
|
|
|
|
|
<p><u>Browser Configuration</u></p>
|
|
|
|
<div class="form-group row">
|
|
|
|
<label for="os" class="col-sm-3 col-form-label">Operating System:</label>
|
|
|
|
<div class="col-sm-7">
|
|
|
|
<select class="form-control" name="os" id="os">
|
|
|
|
{% for os in user_agents.keys() %}
|
2019-03-29 20:11:44 +01:00
|
|
|
<option value="{{ os }}">{{ os }}</option>
|
2019-06-27 17:47:21 +02:00
|
|
|
{% endfor%}
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2019-03-29 20:11:44 +01:00
|
|
|
{% for os, browsers in user_agents.items() %}
|
2019-06-27 17:47:21 +02:00
|
|
|
<div id="{{os.replace(' ', '_')}}" class="style-sub-1 form-group row" {% if loop.index0 != 0 %}style="display: none;"{%endif%}>
|
|
|
|
<div class="col-sm-10">
|
|
|
|
<label for="browser" class="col-sm-3 col-form-label">Browser Type:</label>
|
2019-03-29 20:11:44 +01:00
|
|
|
<select class="form-control" name="browser">
|
2019-06-27 17:47:21 +02:00
|
|
|
{% for browser in browsers.keys()%}
|
|
|
|
<option value="{{ browser }}">{{ browser }}</option>
|
|
|
|
{% endfor%}
|
2019-03-29 20:11:44 +01:00
|
|
|
</select>
|
2019-06-27 17:47:21 +02:00
|
|
|
</div>
|
2019-03-29 20:11:44 +01:00
|
|
|
</div>
|
2019-06-27 17:47:21 +02:00
|
|
|
{% set outer_loop = loop %}
|
|
|
|
{% for browser, user_agents in browsers.items()%}
|
|
|
|
<div id="{{os.replace(' ', '_')}}_{{browser.replace(' ', '_')}}" class="style-sub-2 form-group row" {% if not loop.first or not outer_loop.first %} style="display: none;"{%endif%}>
|
|
|
|
<div class="col-sm-10">
|
|
|
|
<label for="user_agent" class="col-sm-3 col-form-label">User Agent:</label>
|
|
|
|
<select class="form-control" name="user_agent">
|
|
|
|
{% for user_agent in user_agents %}
|
|
|
|
<option value="{{ user_agent }}" >{{ user_agent }}</option>
|
2019-03-29 20:11:44 +01:00
|
|
|
{% endfor%}
|
2019-06-27 17:47:21 +02:00
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{% endfor%}
|
2019-03-29 20:11:44 +01:00
|
|
|
{% endfor%}
|
2019-06-27 17:47:21 +02:00
|
|
|
<center><button type="submit" class="btn btn-default">Start looking!</button></center>
|
2017-07-23 19:56:51 +02:00
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
{% endblock %}
|
2019-03-29 20:11:44 +01:00
|
|
|
|
|
|
|
{% block scripts %}
|
|
|
|
{{ super() }}
|
|
|
|
<script>
|
|
|
|
$("#os").change(function(){
|
|
|
|
var os_name = $(this).find(":selected").val().replace(/(:|\.|\[|\]|,|=)/g, "\\$1").replace(/ /g,"_");
|
|
|
|
var first_browser_name = $("[id='" + os_name + "']").find('select option:first-child').val().replace(/(:|\.|\[|\]|,|=)/g, "\\$1").replace(/ /g,"_");
|
2019-04-02 23:05:31 +02:00
|
|
|
// Hide and disable everything
|
2019-03-29 20:11:44 +01:00
|
|
|
$(".style-sub-1").hide();
|
2019-04-02 23:05:31 +02:00
|
|
|
$(".style-sub-1 > select").attr('disabled', true);
|
2019-03-29 20:11:44 +01:00
|
|
|
$(".style-sub-2").hide();
|
2019-04-02 23:05:31 +02:00
|
|
|
$(".style-sub-2 > select").attr('disabled', true);
|
|
|
|
|
2019-03-29 20:11:44 +01:00
|
|
|
$("[id='" + os_name + "']").show();
|
2019-04-02 23:05:31 +02:00
|
|
|
$("[id='" + os_name + "'] > select").removeAttr('disabled');
|
2019-03-29 20:11:44 +01:00
|
|
|
$("[id='" + os_name + '_' + first_browser_name + "']").show();
|
2019-04-02 23:05:31 +02:00
|
|
|
$("[id='" + os_name + '_' + first_browser_name + "'] > select").removeAttr('disabled');
|
2019-03-29 20:11:44 +01:00
|
|
|
});
|
|
|
|
$('select[name="browser"]').change(function(){
|
|
|
|
var browser_name = $(this).find(":selected").val().replace(/(:|\.|\[|\]|,|=)/g, "\\$1").replace(/ /g,"_");
|
2019-06-27 17:47:21 +02:00
|
|
|
var os_name = $(this).parent().parent().attr("id").replace(/(:|\.|\[|\]|,|=)/g, "\\$1").replace(/ /g,"_");
|
2019-04-02 23:05:31 +02:00
|
|
|
|
|
|
|
// Hide what makes sense
|
2019-03-29 20:11:44 +01:00
|
|
|
$(".style-sub-2").hide();
|
2019-04-02 23:05:31 +02:00
|
|
|
$(".style-sub-2 > select").attr('disabled', true);
|
|
|
|
|
2019-03-29 20:11:44 +01:00
|
|
|
$("[id='" + os_name + '_' + browser_name + "']").show();
|
2019-04-02 23:05:31 +02:00
|
|
|
$("[id='" + os_name + '_' + browser_name + "'] > select").removeAttr('disabled');
|
2019-03-29 20:11:44 +01:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
{% endblock %}
|