Browse Source

Initial commit

master
Notisset 5 years ago
commit
35b9762019
  1. 2
      .gitignore
  2. 11
      .idea/capotreno.iml
  3. 7
      .idea/misc.xml
  4. 8
      .idea/modules.xml
  5. 409
      .idea/workspace.xml
  6. 86
      TestScraper.py
  7. 2953
      elenco_stazioni.txt
  8. 42
      scraper.py

2
.gitignore

@ -0,0 +1,2 @@
.idea

11
.idea/capotreno.iml

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
</component>
</module>

7
.idea/misc.xml

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PreferredVcsStorage">
<preferredVcsName>ApexVCS</preferredVcsName>
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6.2 (/usr/local/bin/python3)" project-jdk-type="Python SDK" />
</project>

8
.idea/modules.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/capotreno.iml" filepath="$PROJECT_DIR$/.idea/capotreno.iml" />
</modules>
</component>
</project>

409
.idea/workspace.xml

@ -0,0 +1,409 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="cd4c1493-bad8-4091-80b2-0ca10f2c3c96" name="Default" comment="" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="CoverageDataManager">
<SUITE FILE_PATH="coverage/capotreno$Unittests_in_TestScraper_py.coverage" NAME="Unittests in TestScraper.py Coverage Results" MODIFIED="1507742625995" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/capotreno$Unittests_for_TestScraper_KnownValues.coverage" NAME="Unittests for TestScraper.KnownValues Coverage Results" MODIFIED="1507674449261" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/capotreno$Unittests_for_TestScraper_KnownValues_test_find_station.coverage" NAME="Unittests for TestScraper.KnownValues.test_find_station Coverage Results" MODIFIED="1507743253230" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/capotreno$Unittests_for_TestScraper_KnownValues_test_get_stations.coverage" NAME="Unittests for TestScraper.KnownValues.test_get_stations Coverage Results" MODIFIED="1507742532246" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/capotreno$Unittests_for_TestScraper_KnownValues_test_instance.coverage" NAME="Unittests for TestScraper.KnownValues.test_instance Coverage Results" MODIFIED="1507672071822" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/capotreno$scraper.coverage" NAME="scraper Coverage Results" MODIFIED="1507743037590" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/capotreno$Unittests_for_TestScraper_KnownValues_test_parse_station.coverage" NAME="Unittests for TestScraper.KnownValues.test_parse_station Coverage Results" MODIFIED="1507674309278" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="elenco_stazioni.txt" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/elenco_stazioni.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="28800">
<caret line="1600" column="0" lean-forward="false" selection-start-line="1600" selection-start-column="0" selection-end-line="1600" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="TestScraper.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/TestScraper.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="828">
<caret line="46" column="0" lean-forward="false" selection-start-line="46" selection-start-column="0" selection-end-line="46" selection-end-column="0" />
<folding>
<element signature="e#30#45#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="scraper.py" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/scraper.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="720">
<caret line="40" column="57" lean-forward="false" selection-start-line="40" selection-start-column="57" selection-end-line="40" selection-end-column="57" />
<folding>
<element signature="e#0#29#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>arcangelo</find>
</findStrings>
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/elenco_stazioni.txt" />
<option value="$PROJECT_DIR$/scraper.py" />
<option value="$PROJECT_DIR$/TestScraper.py" />
</list>
</option>
</component>
<component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
<component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
<component name="JsGulpfileManager">
<detection-done>true</detection-done>
<sorting>DEFINITION_ORDER</sorting>
</component>
<component name="ProjectFrameBounds">
<option name="width" value="1920" />
<option name="height" value="1063" />
</component>
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1">
<flattenPackages />
<showMembers />
<showModules />
<showLibraryContents />
<hideEmptyPackages />
<abbreviatePackageNames />
<autoscrollToSource />
<autoscrollFromSource />
<sortByType />
<manualOrder />
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scratches" />
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="capotreno" type="b2602c69:ProjectViewProjectNode" />
<item name="capotreno" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
</panes>
</component>
<component name="PropertiesComponent">
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager" selected="Python tests.Unittests for TestScraper.KnownValues.test_find_station">
<configuration name="Unittests for TestScraper.KnownValues" type="tests" factoryName="Unittests" temporary="true" nameIsGenerated="true">
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs />
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<module name="capotreno" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
<option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;TestScraper.KnownValues&quot;" />
<option name="_new_targetType" value="&quot;PYTHON&quot;" />
</configuration>
<configuration name="Unittests for TestScraper.KnownValues.test_find_station" type="tests" factoryName="Unittests" temporary="true" nameIsGenerated="true">
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs />
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<module name="capotreno" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
<option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;TestScraper.KnownValues.test_find_station&quot;" />
<option name="_new_targetType" value="&quot;PYTHON&quot;" />
</configuration>
<configuration name="Unittests for TestScraper.KnownValues.test_get_stations" type="tests" factoryName="Unittests" temporary="true" nameIsGenerated="true">
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs />
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<module name="capotreno" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
<option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;TestScraper.KnownValues.test_get_stations&quot;" />
<option name="_new_targetType" value="&quot;PYTHON&quot;" />
</configuration>
<configuration name="Unittests in TestScraper.py" type="tests" factoryName="Unittests" temporary="true" nameIsGenerated="true">
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs />
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<module name="capotreno" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
<option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;$PROJECT_DIR$/TestScraper.py&quot;" />
<option name="_new_targetType" value="&quot;PATH&quot;" />
</configuration>
<configuration name="scraper" type="PythonConfigurationType" factoryName="Python" temporary="true">
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<module name="capotreno" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/scraper.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
</configuration>
<list size="5">
<item index="0" class="java.lang.String" itemvalue="Python tests.Unittests in TestScraper.py" />
<item index="1" class="java.lang.String" itemvalue="Python tests.Unittests for TestScraper.KnownValues" />
<item index="2" class="java.lang.String" itemvalue="Python.scraper" />
<item index="3" class="java.lang.String" itemvalue="Python tests.Unittests for TestScraper.KnownValues.test_get_stations" />
<item index="4" class="java.lang.String" itemvalue="Python tests.Unittests for TestScraper.KnownValues.test_find_station" />
</list>
<recent_temporary>
<list size="5">
<item index="0" class="java.lang.String" itemvalue="Python tests.Unittests for TestScraper.KnownValues.test_find_station" />
<item index="1" class="java.lang.String" itemvalue="Python.scraper" />
<item index="2" class="java.lang.String" itemvalue="Python tests.Unittests in TestScraper.py" />
<item index="3" class="java.lang.String" itemvalue="Python tests.Unittests for TestScraper.KnownValues.test_get_stations" />
<item index="4" class="java.lang.String" itemvalue="Python tests.Unittests for TestScraper.KnownValues" />
</list>
</recent_temporary>
</component>
<component name="ShelveChangesManager" show_recycled="false">
<option name="remove_strategy" value="false" />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="cd4c1493-bad8-4091-80b2-0ca10f2c3c96" name="Default" comment="" />
<created>1507671907028</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1507671907028</updated>
</task>
<servers />
</component>
<component name="TestHistory">
<history-entry file="Unittests_for_TestScraper_KnownValues_test_find_station - 2017.10.11 at 19h 30m 39s.xml">
<configuration name="Unittests for TestScraper.KnownValues.test_find_station" configurationId="tests" />
</history-entry>
<history-entry file="Unittests_for_TestScraper_KnownValues_test_find_station - 2017.10.11 at 19h 31m 38s.xml">
<configuration name="Unittests for TestScraper.KnownValues.test_find_station" configurationId="tests" />
</history-entry>
<history-entry file="Unittests_for_TestScraper_KnownValues_test_find_station - 2017.10.11 at 19h 31m 49s.xml">
<configuration name="Unittests for TestScraper.KnownValues.test_find_station" configurationId="tests" />
</history-entry>
<history-entry file="Unittests_for_TestScraper_KnownValues_test_find_station - 2017.10.11 at 19h 31m 59s.xml">
<configuration name="Unittests for TestScraper.KnownValues.test_find_station" configurationId="tests" />
</history-entry>
<history-entry file="Unittests_for_TestScraper_KnownValues_test_find_station - 2017.10.11 at 19h 32m 31s.xml">
<configuration name="Unittests for TestScraper.KnownValues.test_find_station" configurationId="tests" />
</history-entry>
<history-entry file="Unittests_for_TestScraper_KnownValues_test_find_station - 2017.10.11 at 19h 33m 56s.xml">
<configuration name="Unittests for TestScraper.KnownValues.test_find_station" configurationId="tests" />
</history-entry>
<history-entry file="Unittests_for_TestScraper_KnownValues_test_find_station - 2017.10.11 at 19h 34m 13s.xml">
<configuration name="Unittests for TestScraper.KnownValues.test_find_station" configurationId="tests" />
</history-entry>
<history-entry file="Unittests_for_TestScraper_KnownValues_test_get_stations - 2017.10.11 at 19h 22m 12s.xml">
<configuration name="Unittests for TestScraper.KnownValues.test_get_stations" configurationId="tests" />
</history-entry>
<history-entry file="Unittests_in_TestScraper_py - 2017.10.11 at 19h 22m 15s.xml">
<configuration name="Unittests in TestScraper.py" configurationId="tests" />
</history-entry>
<history-entry file="Unittests_in_TestScraper_py - 2017.10.11 at 19h 23m 46s.xml">
<configuration name="Unittests in TestScraper.py" configurationId="tests" />
</history-entry>
</component>
<component name="ToolWindowManager">
<frame x="0" y="0" width="1920" height="1063" extended-state="0" />
<editor active="true" />
<layout>
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Python Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.36808512" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32978722" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.19444445" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Docker" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Data View" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
</layout>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager />
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/elenco_stazioni.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="28800">
<caret line="1600" column="0" lean-forward="false" selection-start-line="1600" selection-start-column="0" selection-end-line="1600" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/TestScraper.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="792">
<caret line="46" column="0" lean-forward="false" selection-start-line="46" selection-start-column="0" selection-end-line="46" selection-end-column="0" />
<folding>
<element signature="e#30#45#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/scraper.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="684">
<caret line="40" column="57" lean-forward="false" selection-start-line="40" selection-start-column="57" selection-end-line="40" selection-end-column="57" />
<folding>
<element signature="e#0#29#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/elenco_stazioni.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="36">
<caret line="2" column="19" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="2" selection-end-column="19" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/TestScraper.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="270">
<caret line="17" column="0" lean-forward="false" selection-start-line="17" selection-start-column="0" selection-end-line="17" selection-end-column="0" />
<folding>
<element signature="e#30#45#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file:///usr/local/lib/python3.6/unittest/case.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="19782">
<caret line="1112" column="0" lean-forward="false" selection-start-line="1112" selection-start-column="0" selection-end-line="1112" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/scraper.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="72">
<caret line="6" column="145" lean-forward="false" selection-start-line="6" selection-start-column="145" selection-end-line="6" selection-end-column="145" />
<folding>
<element signature="e#0#29#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/response.json" />
<entry file="file:///usr/local/lib/python3.6/unittest/case.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-393">
<caret line="1112" column="0" lean-forward="false" selection-start-line="1112" selection-start-column="0" selection-end-line="1112" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/elenco_stazioni.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="28800">
<caret line="1600" column="0" lean-forward="false" selection-start-line="1600" selection-start-column="0" selection-end-line="1600" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/TestScraper.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="828">
<caret line="46" column="0" lean-forward="false" selection-start-line="46" selection-start-column="0" selection-end-line="46" selection-end-column="0" />
<folding>
<element signature="e#30#45#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/scraper.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="720">
<caret line="40" column="57" lean-forward="false" selection-start-line="40" selection-start-column="57" selection-end-line="40" selection-end-column="57" />
<folding>
<element signature="e#0#29#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
</project>

86
TestScraper.py

@ -0,0 +1,86 @@
# TestCalculatorFunctions.py
import unittest
from scraper import Scraper
from pprint import pprint
class KnownValues(unittest.TestCase):
scraper = Scraper();
def test_instance(self):
self.assertIsInstance(self.scraper, Scraper)
def test_get_stations(self):
fname = 'elenco_stazioni.txt'
stations = self.scraper.get_stations(fname)
with open(fname) as fopen:
self.assertEqual(len(stations), len(list(fopen)))
for station in stations:
self.assertTrue('name' in station)
self.assertTrue('code' in station)
def test_parse_stations(self):
source = '''BARI CENTRALE|S11119
BARI TORRE QUETTA|S11004
BOLOGNA C.LE|S05043'''
stations = self.scraper.parse_stations(source)
self.assertListEqual(stations, [
{'name': 'BARI CENTRALE', 'code': 'S11119'},
{'name': 'BARI TORRE QUETTA', 'code': 'S11004'},
{'name': 'BOLOGNA C.LE', 'code': 'S05043'},
])
for station in stations:
self.assertTrue('name' in station)
self.assertTrue('code' in station)
def test_parse_station(self):
station = 'SAN LEONARDO DI CUTRO|S11827'
expected = {'name': 'SAN LEONARDO DI CUTRO', 'code': 'S11827'}
self.assertDictEqual(self.scraper.parse_station(station), expected)
def test_find_station(self):
station_name = 'monz'
fname = 'elenco_stazioni.txt'
stations = self.scraper.get_stations(fname)
expected = [
{'name': 'MONZA', 'code': 'S01322'},
{'name': 'MONZA SOBBORGHI', 'code': 'S01480'},
{'name': 'MONZONE-M.DEI BANCHI-ISOLANO', 'code': 'S06225'},
{'name': 'MONZUNO', 'code': 'S05132'},
]
self.assertListEqual(self.scraper.find_stations(station_name, stations), expected)
# def test_can_connect(self):
# scraper = Scraper()
# self.assertEqual(scraper.touch('http://ddg.gg'), 200)
#
# def test_get_page(self):
# scraper = Scraper()
# self.assertEqual(scraper.get_page().status_code, 200)
#
# def test_format_hackerspace(self):
# scraper = Scraper()
# hackerspace = {'name':'pippo'}
# formatted = scraper.format_hackerspace(hackerspace)
# self.assertTrue('url' in formatted)
#
#
# def test_get_hackerspaces(self):
# scraper = Scraper()
# hackerspaces = scraper.get_hackerspaces()
# self.assertGreater(len(hackerspaces), 0)
#
# for hackerspace in hackerspaces:
# self.assertTrue('url' in hackerspace)
#
# def test_convert_text_field_to_hs_url(self):
# scraper = Scraper()
# textfield = '<b><a href="/Freaknet" title="Freaknet">Freaknet</a></b>'
# self.assertEqual(scraper.convert_text_field_to_hs_url(textfield), 'https://wiki.hackerspaces.org/Freaknet')
if __name__ == '__main__':
unittest.main()

2953
elenco_stazioni.txt

File diff suppressed because it is too large

42
scraper.py

@ -0,0 +1,42 @@
from bs4 import BeautifulSoup
import requests, json
from pprint import pprint
class Scraper():
url = 'http://www.viaggiatreno.it/viaggiatrenonew/resteasy/viaggiatreno/partenze/S01480/Tue%20Oct%2011%202017%2008:30:00%20GMT+0200%20(CEST)'
def __init__(self):
pass
def get_stations(self, filename):
_ret = []
with open(filename) as file:
return self.parse_stations(file.read())
return _ret
def parse_stations(self, stations):
_ret = []
for station in stations.split('\n'):
if len(station) > 0:
_ret.append(self.parse_station(station))
return _ret
def parse_station(self, station):
stat = station.split('|')
return {
'name': stat[0].strip(),
'code': stat[1].strip()
}
def find_stations(self, station_name, stations):
_ret = []
for station in stations:
if station_name.lower() in station['name'].lower():
_ret.append(station)
return _ret
if __name__ == '__main__':
scraper = Scraper()
stations = scraper.get_stations('elenco_stazioni.txt')
pprint(stations)
Loading…
Cancel
Save