File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -70,15 +70,26 @@ public static List<VillageChecked> GetVillages(HtmlAgilityPack.HtmlDocument html
70
70
if ( node . HasClass ( "active" ) )
71
71
active = true ;
72
72
73
- var href = System . Net . WebUtility . HtmlDecode ( node . ChildNodes . First ( x => x . Name == "a" ) . GetAttributeValue ( "href" , "" ) ) ;
74
-
73
+ var href = System . Net . WebUtility . HtmlDecode ( node . ChildNodes . FirstOrDefault ( x => x . Name == "a" ) . GetAttributeValue ( "href" , "" ) ) ;
75
74
var villId = Convert . ToInt32 ( href . Split ( '=' ) [ 1 ] . Split ( '&' ) [ 0 ] ) ;
75
+ var villName = node . Descendants ( "a" ) . FirstOrDefault ( ) . InnerText . Replace ( " " , "" ) . Replace ( "\r \n " , "" ) ;
76
76
77
- var villName = node . Descendants ( ) . FirstOrDefault ( x => x . HasClass ( "name" ) ) . InnerText ;
77
+ var x_node = node . Descendants ( "span" ) . FirstOrDefault ( x => x . HasClass ( "coordinateX" ) ) ;
78
+ int x_coord = 0 ;
79
+ if ( x_node != null )
80
+ {
81
+ x_coord = ( int ) Parser . ParseNum ( x_node . InnerText . Replace ( "(" , "" ) ) ;
82
+ }
83
+ var y_node = node . Descendants ( "span" ) . FirstOrDefault ( x => x . HasClass ( "coordinateY" ) ) ;
84
+ int y_coord = 0 ;
85
+ if ( y_node != null )
86
+ {
87
+ y_coord = ( int ) Parser . ParseNum ( y_node . InnerText . Replace ( ")" , "" ) ) ;
88
+ }
78
89
var coords = new Coordinates ( )
79
90
{
80
- x = ( int ) Parser . ParseNum ( node . Descendants ( "span" ) . FirstOrDefault ( x => x . HasClass ( "coordinateX" ) ) . InnerText . Replace ( "(" , "" ) ) ,
81
- y = ( int ) Parser . ParseNum ( node . Descendants ( "span" ) . FirstOrDefault ( x => x . HasClass ( "coordinateY" ) ) . InnerText . Replace ( ")" , "" ) )
91
+ x = x_coord ,
92
+ y = y_coord ,
82
93
} ;
83
94
84
95
ret . Add ( new VillageChecked ( )
You can’t perform that action at this time.
0 commit comments