mirror of
https://github.com/Dvorinka/facr-scraper.git
synced 2026-06-05 04:52:56 +00:00
first commit
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
module facr-scraper
|
||||||
|
|
||||||
|
go 1.24.1
|
||||||
|
|
||||||
|
toolchain go1.24.4
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/PuerkitoBio/goquery v1.10.3
|
||||||
|
github.com/gorilla/mux v1.8.1
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/andybalholm/cascadia v1.3.3 // indirect
|
||||||
|
github.com/chromedp/cdproto v0.0.0-20250803210736-d308e07a266d // indirect
|
||||||
|
github.com/chromedp/chromedp v0.14.1 // indirect
|
||||||
|
github.com/chromedp/sysutil v1.1.0 // indirect
|
||||||
|
github.com/go-json-experiment/json v0.0.0-20250813024750-ebf49471dced // indirect
|
||||||
|
github.com/go-rod/rod v0.108.1 // indirect
|
||||||
|
github.com/gobwas/httphead v0.1.0 // indirect
|
||||||
|
github.com/gobwas/pool v0.2.1 // indirect
|
||||||
|
github.com/gobwas/ws v1.4.0 // indirect
|
||||||
|
github.com/ledongthuc/pdf v0.0.0-20250511090121-5959a4027728 // indirect
|
||||||
|
github.com/ysmood/fetchup v0.5.2 // indirect
|
||||||
|
github.com/ysmood/goob v0.4.0 // indirect
|
||||||
|
github.com/ysmood/got v0.41.0 // indirect
|
||||||
|
github.com/ysmood/gson v0.7.3 // indirect
|
||||||
|
github.com/ysmood/leakless v0.9.0 // indirect
|
||||||
|
golang.org/x/net v0.43.0 // indirect
|
||||||
|
golang.org/x/sys v0.35.0 // indirect
|
||||||
|
)
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
github.com/PuerkitoBio/goquery v1.8.1 h1:uQxhNlArOIdbrH1tr0UXwdVFgDcZDrZVdcpygAcwmWM=
|
||||||
|
github.com/PuerkitoBio/goquery v1.8.1/go.mod h1:Q8ICL1kNUJ2sXGoAhPGUdYDJvgQgHzJsnnd3H7Ho5jQ=
|
||||||
|
github.com/PuerkitoBio/goquery v1.10.3 h1:pFYcNSqHxBD06Fpj/KsbStFRsgRATgnf3LeXiUkhzPo=
|
||||||
|
github.com/PuerkitoBio/goquery v1.10.3/go.mod h1:tMUX0zDMHXYlAQk6p35XxQMqMweEKB7iK7iLNd4RH4Y=
|
||||||
|
github.com/andybalholm/cascadia v1.3.1 h1:nhxRkql1kdYCc8Snf7D5/D3spOX+dBgjA6u8x004T2c=
|
||||||
|
github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA=
|
||||||
|
github.com/andybalholm/cascadia v1.3.3 h1:AG2YHrzJIm4BZ19iwJ/DAua6Btl3IwJX+VI4kktS1LM=
|
||||||
|
github.com/andybalholm/cascadia v1.3.3/go.mod h1:xNd9bqTn98Ln4DwST8/nG+H0yuB8Hmgu1YHNnWw0GeA=
|
||||||
|
github.com/chromedp/cdproto v0.0.0-20250803210736-d308e07a266d h1:ZtA1sedVbEW7EW80Iz2GR3Ye6PwbJAJXjv7D74xG6HU=
|
||||||
|
github.com/chromedp/cdproto v0.0.0-20250803210736-d308e07a266d/go.mod h1:NItd7aLkcfOA/dcMXvl8p1u+lQqioRMq/SqDp71Pb/k=
|
||||||
|
github.com/chromedp/chromedp v0.14.1 h1:0uAbnxewy/Q+Bg7oafVePE/6EXEho9hnaC38f+TTENg=
|
||||||
|
github.com/chromedp/chromedp v0.14.1/go.mod h1:rHzAv60xDE7VNy/MYtTUrYreSc0ujt2O1/C3bzctYBo=
|
||||||
|
github.com/chromedp/sysutil v1.1.0 h1:PUFNv5EcprjqXZD9nJb9b/c9ibAbxiYo4exNWZyipwM=
|
||||||
|
github.com/chromedp/sysutil v1.1.0/go.mod h1:WiThHUdltqCNKGc4gaU50XgYjwjYIhKWoHGPTUfWTJ8=
|
||||||
|
github.com/go-json-experiment/json v0.0.0-20250813024750-ebf49471dced h1:Q311OHjMh/u5E2TITc++WlTP5We0xNseRMkHDyvhW7I=
|
||||||
|
github.com/go-json-experiment/json v0.0.0-20250813024750-ebf49471dced/go.mod h1:TiCD2a1pcmjd7YnhGH0f/zKNcCD06B029pHhzV23c2M=
|
||||||
|
github.com/go-rod/rod v0.100.0 h1:tEKIb5wS3pGUpW4oJPYDxOKmRXaZbd6S+YVjJ6BHBBY=
|
||||||
|
github.com/go-rod/rod v0.100.0/go.mod h1:h9igqSGReLmOWyHtdf0AtUd0mdkHFu3gFwBeV+stleM=
|
||||||
|
github.com/go-rod/rod v0.108.1 h1:2lKs+v/+B/2pbGKZgNIRbURhduTKNDZ3PXIvTRAV2Mg=
|
||||||
|
github.com/go-rod/rod v0.108.1/go.mod h1:yNvL687cwcjgebRuArQN9AStFdm8iS/e/rzImrS9Pzg=
|
||||||
|
github.com/go-rod/rod v0.114.0 h1:P+zLOqsj+vKf4C86SfjP6ymyPl9VXoYKm+ceCeQms6Y=
|
||||||
|
github.com/go-rod/rod v0.114.0/go.mod h1:aiedSEFg5DwG/fnNbUOTPMTTWX3MRj6vIs/a684Mthw=
|
||||||
|
github.com/go-rod/rod v0.116.2 h1:A5t2Ky2A+5eD/ZJQr1EfsQSe5rms5Xof/qj296e+ZqA=
|
||||||
|
github.com/go-rod/rod v0.116.2/go.mod h1:H+CMO9SCNc2TJ2WfrG+pKhITz57uGNYU43qYHh438Mg=
|
||||||
|
github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU=
|
||||||
|
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
|
||||||
|
github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og=
|
||||||
|
github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
|
||||||
|
github.com/gobwas/ws v1.4.0 h1:CTaoG1tojrh4ucGPcoJFiAQUAsEWekEWvLy7GsVNqGs=
|
||||||
|
github.com/gobwas/ws v1.4.0/go.mod h1:G3gNqMNtPppf5XUz7O4shetPpcZ1VJ7zt18dlUeakrc=
|
||||||
|
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
|
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
|
||||||
|
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
|
||||||
|
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
|
||||||
|
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
|
||||||
|
github.com/ledongthuc/pdf v0.0.0-20250511090121-5959a4027728 h1:QwWKgMY28TAXaDl+ExRDqGQltzXqN/xypdKP86niVn8=
|
||||||
|
github.com/ledongthuc/pdf v0.0.0-20250511090121-5959a4027728/go.mod h1:1fEHWurg7pvf5SG6XNE5Q8UZmOwex51Mkx3SLhrW5B4=
|
||||||
|
github.com/ysmood/fetchup v0.2.3/go.mod h1:xhibcRKziSvol0H1/pj33dnKrYyI2ebIvz5cOOkYGns=
|
||||||
|
github.com/ysmood/fetchup v0.5.2 h1:P9w3OIA7RSNEEFvEmOiTq09IOu42C96PMyZ1MWd8TAs=
|
||||||
|
github.com/ysmood/fetchup v0.5.2/go.mod h1:yCv8s8itjsCul1LGXJ1Q+8EQnZcVjfbZ4+l1zDm4StE=
|
||||||
|
github.com/ysmood/goob v0.3.0/go.mod h1:S3lq113Y91y1UBf1wj1pFOxeahvfKkCk6mTWTWbDdWs=
|
||||||
|
github.com/ysmood/goob v0.4.0 h1:HsxXhyLBeGzWXnqVKtmT9qM7EuVs/XOgkX7T6r1o1AQ=
|
||||||
|
github.com/ysmood/goob v0.4.0/go.mod h1:u6yx7ZhS4Exf2MwciFr6nIM8knHQIE22lFpWHnfql18=
|
||||||
|
github.com/ysmood/gop v0.0.2/go.mod h1:rr5z2z27oGEbyB787hpEcx4ab8cCiPnKxn0SUHt6xzk=
|
||||||
|
github.com/ysmood/got v0.12.0/go.mod h1:pE1l4LOwOBhQg6A/8IAatkGp7uZjnalzrZolnlhhMgY=
|
||||||
|
github.com/ysmood/got v0.31.2/go.mod h1:pE1l4LOwOBhQg6A/8IAatkGp7uZjnalzrZolnlhhMgY=
|
||||||
|
github.com/ysmood/got v0.34.1/go.mod h1:yddyjq/PmAf08RMLSwDjPyCvHvYed+WjHnQxpH851LM=
|
||||||
|
github.com/ysmood/got v0.41.0 h1:XiFH311ltTSGyxjeKcNvy7dzbJjjTzn6DBgK313JHBs=
|
||||||
|
github.com/ysmood/got v0.41.0/go.mod h1:W7DdpuX6skL3NszLmAsC5hT7JAhuLZhByVzHTq874Qg=
|
||||||
|
github.com/ysmood/gotrace v0.2.2/go.mod h1:TzhIG7nHDry5//eYZDYcTzuJLYQIkykJzCRIo4/dzQM=
|
||||||
|
github.com/ysmood/gotrace v0.6.0/go.mod h1:TzhIG7nHDry5//eYZDYcTzuJLYQIkykJzCRIo4/dzQM=
|
||||||
|
github.com/ysmood/gson v0.6.4/go.mod h1:3Kzs5zDl21g5F/BlLTNcuAGAYLKt2lV5G8D1zF3RNmg=
|
||||||
|
github.com/ysmood/gson v0.7.1/go.mod h1:3Kzs5zDl21g5F/BlLTNcuAGAYLKt2lV5G8D1zF3RNmg=
|
||||||
|
github.com/ysmood/gson v0.7.3 h1:QFkWbTH8MxyUTKPkVWAENJhxqdBa4lYTQWqZCiLG6kE=
|
||||||
|
github.com/ysmood/gson v0.7.3/go.mod h1:3Kzs5zDl21g5F/BlLTNcuAGAYLKt2lV5G8D1zF3RNmg=
|
||||||
|
github.com/ysmood/leakless v0.7.0/go.mod h1:R8iAXPRaG97QJwqxs74RdwzcRHT1SWCGTNqY8q0JvMQ=
|
||||||
|
github.com/ysmood/leakless v0.8.0/go.mod h1:R8iAXPRaG97QJwqxs74RdwzcRHT1SWCGTNqY8q0JvMQ=
|
||||||
|
github.com/ysmood/leakless v0.9.0 h1:qxCG5VirSBvmi3uynXFkcnLMzkphdh3xx5FtrORwDCU=
|
||||||
|
github.com/ysmood/leakless v0.9.0/go.mod h1:R8iAXPRaG97QJwqxs74RdwzcRHT1SWCGTNqY8q0JvMQ=
|
||||||
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
|
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
|
||||||
|
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||||
|
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||||
|
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
|
||||||
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
|
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||||
|
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||||
|
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||||
|
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||||
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
|
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
|
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
|
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
|
||||||
|
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
|
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||||
|
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
|
||||||
|
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||||
|
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||||
|
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
|
||||||
|
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
|
||||||
|
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
|
||||||
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
|
||||||
|
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
|
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
|
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
|
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
|
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
|
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
|
||||||
|
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||||
|
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
|
||||||
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
|
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||||
|
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||||
|
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
|
||||||
|
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||||
|
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
|
||||||
|
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
|
||||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
|
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
|
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||||
|
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||||
|
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
|
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
|
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||||
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||||
|
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||||
|
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
|
||||||
|
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||||
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
@@ -0,0 +1,733 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
neturl "net/url"
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/PuerkitoBio/goquery"
|
||||||
|
"github.com/gorilla/mux"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Competition struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
Code string `json:"code"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
TeamCount string `json:"team_count"`
|
||||||
|
MatchesLink string `json:"matches_link"`
|
||||||
|
Matches []Match `json:"matches,omitempty"`
|
||||||
|
Table *CompetitionTable `json:"table,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Logo resolution via local /club/search with simple in-memory cache ---
|
||||||
|
var logoCache = map[string]string{}
|
||||||
|
|
||||||
|
type searchAPIResult struct {
|
||||||
|
Results []struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
LogoURL string `json:"logo_url"`
|
||||||
|
} `json:"results"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func getLogoBySearch(name string) string {
|
||||||
|
key := strings.ToLower(strings.TrimSpace(name))
|
||||||
|
if key == "" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
if v, ok := logoCache[key]; ok {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
// Query local API
|
||||||
|
apiURL := fmt.Sprintf("http://localhost:8080/club/search?q=%s", neturl.QueryEscape(name))
|
||||||
|
client := &http.Client{Timeout: 5 * time.Second}
|
||||||
|
resp, err := client.Get(apiURL)
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
// drain body to allow reuse
|
||||||
|
io.Copy(io.Discard, resp.Body)
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
var payload searchAPIResult
|
||||||
|
if err := json.NewDecoder(resp.Body).Decode(&payload); err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
// pick best match: exact (case-insensitive), then contains, else first
|
||||||
|
best := ""
|
||||||
|
for _, r := range payload.Results {
|
||||||
|
if strings.EqualFold(strings.TrimSpace(r.Name), strings.TrimSpace(name)) {
|
||||||
|
best = r.LogoURL
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if best == "" {
|
||||||
|
for _, r := range payload.Results {
|
||||||
|
if strings.Contains(strings.ToLower(r.Name), key) || strings.Contains(key, strings.ToLower(r.Name)) {
|
||||||
|
best = r.LogoURL
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if best == "" && len(payload.Results) > 0 {
|
||||||
|
best = payload.Results[0].LogoURL
|
||||||
|
}
|
||||||
|
logoCache[key] = best
|
||||||
|
return best
|
||||||
|
}
|
||||||
|
|
||||||
|
func getLogo(teamName string, teamID string) string {
|
||||||
|
placeholder := "https://www.fotbal.cz/dist/img/logo-club-empty.svg"
|
||||||
|
name := strings.ToLower(strings.TrimSpace(teamName))
|
||||||
|
if name == "" || strings.Contains(name, "volno") || strings.Contains(name, "volný los") || strings.Contains(name, "volny los") || strings.Contains(name, "bye") {
|
||||||
|
return placeholder
|
||||||
|
}
|
||||||
|
// Try search endpoint
|
||||||
|
if logo := getLogoBySearch(teamName); logo != "" {
|
||||||
|
return logo
|
||||||
|
}
|
||||||
|
// Fallback to constructed URL if we have an ID
|
||||||
|
tid := strings.TrimSpace(teamID)
|
||||||
|
if tid != "" {
|
||||||
|
return fmt.Sprintf("https://is1.fotbal.cz/media/kluby/%s/%s_crop.jpg", tid, tid)
|
||||||
|
}
|
||||||
|
// No ID and no search hit -> placeholder
|
||||||
|
return placeholder
|
||||||
|
}
|
||||||
|
|
||||||
|
// CompetitionTable holds standings sections; currently only Overall is used
|
||||||
|
type CompetitionTable struct {
|
||||||
|
Overall []TableRow `json:"overall"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClubInfo is the response for club info and tables endpoints
|
||||||
|
type ClubInfo struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
ClubID string `json:"club_id"`
|
||||||
|
ClubType string `json:"club_type"`
|
||||||
|
ClubInternalID string `json:"club_internal_id,omitempty"`
|
||||||
|
URL string `json:"url,omitempty"`
|
||||||
|
LogoURL string `json:"logo_url,omitempty"`
|
||||||
|
Address string `json:"address,omitempty"`
|
||||||
|
Category string `json:"category,omitempty"`
|
||||||
|
Competitions []Competition `json:"competitions"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SearchResult represents one club from fotbal.cz search
|
||||||
|
type SearchResult struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
ClubID string `json:"club_id"`
|
||||||
|
ClubType string `json:"club_type"` // football or futsal
|
||||||
|
URL string `json:"url"`
|
||||||
|
LogoURL string `json:"logo_url"`
|
||||||
|
Category string `json:"category,omitempty"`
|
||||||
|
Address string `json:"address,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// getClubSearch queries fotbal.cz club search and returns results with logo
|
||||||
|
func getClubSearch(w http.ResponseWriter, r *http.Request) {
|
||||||
|
q := strings.TrimSpace(r.URL.Query().Get("q"))
|
||||||
|
if q == "" {
|
||||||
|
http.Error(w, "query parameter 'q' is required", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build search URL
|
||||||
|
vals := neturl.Values{}
|
||||||
|
vals.Set("q", q)
|
||||||
|
searchURL := "https://www.fotbal.cz/club/hledej?" + vals.Encode()
|
||||||
|
|
||||||
|
req, err := http.NewRequest("GET", searchURL, nil)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, fmt.Sprintf("Error creating request: %v", err), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// Set headers to mimic a browser; fotbal.cz may 404 otherwise
|
||||||
|
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0 Safari/537.36")
|
||||||
|
req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8")
|
||||||
|
req.Header.Set("Accept-Language", "cs-CZ,cs;q=0.9,en;q=0.8")
|
||||||
|
req.Header.Set("Referer", "https://www.fotbal.cz/club/hledej")
|
||||||
|
client := &http.Client{}
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, fmt.Sprintf("Error fetching search page: %v", err), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
// Retry once. If query has very short tokens, try quoting the whole query.
|
||||||
|
resp.Body.Close()
|
||||||
|
searchURL2 := searchURL
|
||||||
|
tokens := strings.Fields(q)
|
||||||
|
for _, t := range tokens {
|
||||||
|
if len([]rune(t)) <= 2 {
|
||||||
|
vals2 := neturl.Values{}
|
||||||
|
vals2.Set("q", "\""+q+"\"")
|
||||||
|
searchURL2 = "https://www.fotbal.cz/club/hledej?" + vals2.Encode()
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
req2, _ := http.NewRequest("GET", searchURL2, nil)
|
||||||
|
req2.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0 Safari/537.36")
|
||||||
|
req2.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
|
||||||
|
req2.Header.Set("Accept-Language", "en-US,en;q=0.9")
|
||||||
|
resp2, err2 := client.Do(req2)
|
||||||
|
if err2 != nil {
|
||||||
|
http.Error(w, fmt.Sprintf("Error fetching (retry): %v", err2), http.StatusBadGateway)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer resp2.Body.Close()
|
||||||
|
if resp2.StatusCode != http.StatusOK {
|
||||||
|
// Treat as no results instead of surfacing error to client
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
json.NewEncoder(w).Encode(map[string]any{
|
||||||
|
"query": q,
|
||||||
|
"count": 0,
|
||||||
|
"results": []SearchResult{},
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// replace resp with resp2 for downstream parsing
|
||||||
|
resp = resp2
|
||||||
|
}
|
||||||
|
|
||||||
|
doc, err := goquery.NewDocumentFromReader(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, fmt.Sprintf("Error parsing HTML: %v", err), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var results []SearchResult
|
||||||
|
// The page lists clubs in section "Výsledky hledání" as li.ListItemSplit
|
||||||
|
doc.Find("li.ListItemSplit").Each(func(_ int, li *goquery.Selection) {
|
||||||
|
a := li.Find("a.Link--inverted").First()
|
||||||
|
href, _ := a.Attr("href")
|
||||||
|
if href == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
name := strings.TrimSpace(a.Find("span.H7").First().Text())
|
||||||
|
if name == "" {
|
||||||
|
// fallback to link text
|
||||||
|
name = strings.TrimSpace(a.Text())
|
||||||
|
}
|
||||||
|
img := a.Find("img").First()
|
||||||
|
logoURL, _ := img.Attr("src")
|
||||||
|
|
||||||
|
// Category
|
||||||
|
category := strings.TrimSpace(li.Find(".ClubCategories .BadgeCategory").First().Text())
|
||||||
|
// Address
|
||||||
|
address := strings.TrimSpace(li.Find(".ClubAddress p").First().Text())
|
||||||
|
|
||||||
|
// Infer club type from href
|
||||||
|
clubType := "football"
|
||||||
|
if strings.Contains(strings.ToLower(href), "/futsal/") {
|
||||||
|
clubType = "futsal"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract club ID from last path segment
|
||||||
|
// e.g., https://www.fotbal.cz/futsal/club/club/{uuid}
|
||||||
|
parts := strings.Split(strings.TrimRight(href, "/"), "/")
|
||||||
|
clubID := ""
|
||||||
|
if len(parts) > 0 {
|
||||||
|
clubID = parts[len(parts)-1]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normalize URL (ensure absolute)
|
||||||
|
if !strings.HasPrefix(href, "http://") && !strings.HasPrefix(href, "https://") {
|
||||||
|
href = "https://www.fotbal.cz" + href
|
||||||
|
}
|
||||||
|
|
||||||
|
results = append(results, SearchResult{
|
||||||
|
Name: name,
|
||||||
|
ClubID: clubID,
|
||||||
|
ClubType: clubType,
|
||||||
|
URL: href,
|
||||||
|
LogoURL: logoURL,
|
||||||
|
Category: category,
|
||||||
|
Address: address,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
json.NewEncoder(w).Encode(map[string]any{
|
||||||
|
"query": q,
|
||||||
|
"count": len(results),
|
||||||
|
"results": results,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// getClubTables returns club info with competition standings tables (no matches)
|
||||||
|
func getClubTables(w http.ResponseWriter, r *http.Request) {
|
||||||
|
vars := mux.Vars(r)
|
||||||
|
clubID := vars["id"]
|
||||||
|
clubType := vars["type"]
|
||||||
|
|
||||||
|
if clubID == "" {
|
||||||
|
http.Error(w, "Club ID is required", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate club type
|
||||||
|
var baseURL string
|
||||||
|
var sportParam string
|
||||||
|
switch clubType {
|
||||||
|
case "football":
|
||||||
|
baseURL = "https://www.fotbal.cz/souteze/club/club"
|
||||||
|
sportParam = "fotbal"
|
||||||
|
case "futsal":
|
||||||
|
baseURL = "https://www.fotbal.cz/futsal/club/club"
|
||||||
|
sportParam = "futsal"
|
||||||
|
default:
|
||||||
|
http.Error(w, "Invalid club type. Use 'football' or 'futsal'.", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
url := fmt.Sprintf("%s/%s", baseURL, clubID)
|
||||||
|
resp, err := http.Get(url)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, fmt.Sprintf("Error fetching club data: %v", err), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
http.Error(w, fmt.Sprintf("Error: received status code %d", resp.StatusCode), resp.StatusCode)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
doc, err := goquery.NewDocumentFromReader(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, fmt.Sprintf("Error parsing HTML: %v", err), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// Extract club internal ID
|
||||||
|
clubInternalID := ""
|
||||||
|
doc.Find("section").Each(func(i int, s *goquery.Selection) {
|
||||||
|
headerText := s.Find("h3 span").First().Text()
|
||||||
|
if strings.TrimSpace(headerText) == "ID klubu" {
|
||||||
|
clubInternalID = strings.TrimSpace(s.Find("ul li").First().Text())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// Extract competitions
|
||||||
|
var competitions []Competition
|
||||||
|
doc.Find("table.Table tbody tr").Each(func(i int, s *goquery.Selection) {
|
||||||
|
code := strings.TrimSpace(s.Find("td:first-child").Text())
|
||||||
|
nameLink := s.Find("td:nth-child(2) a")
|
||||||
|
name := strings.TrimSpace(nameLink.Text())
|
||||||
|
teamCount := strings.TrimSpace(s.Find("td:nth-child(3)").Text())
|
||||||
|
// Extract competition ID from the link
|
||||||
|
parts := strings.Split(nameLink.AttrOr("href", ""), "/")
|
||||||
|
compID := ""
|
||||||
|
if len(parts) >= 2 {
|
||||||
|
compID = parts[len(parts)-1]
|
||||||
|
}
|
||||||
|
// Build public table link depending on clubType
|
||||||
|
tableLink := ""
|
||||||
|
if strings.EqualFold(clubType, "futsal") {
|
||||||
|
tableLink = fmt.Sprintf("https://www.fotbal.cz/futsal/futsal/table/%s", compID)
|
||||||
|
} else {
|
||||||
|
tableLink = fmt.Sprintf("https://www.fotbal.cz/souteze/turnaje/table/%s", compID)
|
||||||
|
}
|
||||||
|
|
||||||
|
competitions = append(competitions, Competition{
|
||||||
|
ID: compID,
|
||||||
|
Code: code,
|
||||||
|
Name: name,
|
||||||
|
TeamCount: teamCount,
|
||||||
|
MatchesLink: tableLink,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// For each competition, fetch the standings tables from is.fotbal.cz
|
||||||
|
for i := range competitions {
|
||||||
|
comp := &competitions[i]
|
||||||
|
tableURL := fmt.Sprintf("https://is.fotbal.cz/public/souteze/tabulky-souteze.aspx?req=%s&sport=%s", comp.ID, sportParam)
|
||||||
|
resp, err := http.Get(tableURL)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("error fetching competition table for %s: %v", comp.ID, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
log.Printf("non-200 response for %s: %d", comp.ID, resp.StatusCode)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
docTable, err := goquery.NewDocumentFromReader(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("error parsing table HTML for %s: %v", comp.ID, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse section: Tabulka celková (only overall)
|
||||||
|
var overall []TableRow
|
||||||
|
|
||||||
|
parseSection := func(headerText string) []TableRow {
|
||||||
|
var rows []TableRow
|
||||||
|
// Find the h3 with matching text, then the following .list.tabulky table
|
||||||
|
docTable.Find("h3").EachWithBreak(func(_ int, h3 *goquery.Selection) bool {
|
||||||
|
if strings.EqualFold(strings.TrimSpace(h3.Text()), headerText) {
|
||||||
|
list := h3.NextAllFiltered("div.list.tabulky").First()
|
||||||
|
if list.Length() == 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
table := list.Find("table.vysledky-tabulky tbody")
|
||||||
|
table.Find("tr").Each(func(_ int, tr *goquery.Selection) {
|
||||||
|
// skip header rows containing th
|
||||||
|
if tr.Find("th").Length() > 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tds := tr.Find("td")
|
||||||
|
if tds.Length() < 8 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
get := func(i int) string { return strings.TrimSpace(tds.Eq(i).Text()) }
|
||||||
|
rank := get(0)
|
||||||
|
team := get(1)
|
||||||
|
teamID := extractUUIDFromHref(tds.Eq(1).Find("a").First().AttrOr("href", ""))
|
||||||
|
played := get(2)
|
||||||
|
wins := get(3)
|
||||||
|
draws := get(4)
|
||||||
|
losses := get(5)
|
||||||
|
scoreRaw := get(6)
|
||||||
|
// normalize score like "5 : 0" -> "5:0"
|
||||||
|
score := scoreRaw
|
||||||
|
if re := regexp.MustCompile(`\s*([0-9]+)\s*:\s*([0-9]+)\s*`); re != nil {
|
||||||
|
if m := re.FindStringSubmatch(scoreRaw); len(m) == 3 {
|
||||||
|
score = fmt.Sprintf("%s:%s", m[1], m[2])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
points := get(7)
|
||||||
|
rows = append(rows, TableRow{
|
||||||
|
Rank: rank, Team: team, TeamID: teamID, TeamLogoURL: getLogo(team, teamID), Played: played, Wins: wins, Draws: draws, Losses: losses, Score: score, Points: points,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
return rows
|
||||||
|
}
|
||||||
|
|
||||||
|
overall = parseSection("Tabulka celková")
|
||||||
|
comp.Table = &CompetitionTable{Overall: overall}
|
||||||
|
}
|
||||||
|
|
||||||
|
clubName := strings.TrimSpace(doc.Find("h1.H4 span").First().Text())
|
||||||
|
clubURL := strings.TrimSpace(doc.Find("h1.H4 a").First().AttrOr("href", ""))
|
||||||
|
logoURL := strings.TrimSpace(doc.Find("img.Logo").First().AttrOr("src", ""))
|
||||||
|
category := strings.TrimSpace(doc.Find("section").First().Find("h3 span").First().Text())
|
||||||
|
address := strings.TrimSpace(doc.Find("section").First().Find("ul li").First().Text())
|
||||||
|
|
||||||
|
clubInfo := ClubInfo{
|
||||||
|
Name: clubName,
|
||||||
|
ClubID: clubID,
|
||||||
|
ClubType: clubType,
|
||||||
|
ClubInternalID: clubInternalID,
|
||||||
|
URL: clubURL,
|
||||||
|
LogoURL: logoURL,
|
||||||
|
Address: address,
|
||||||
|
Category: category,
|
||||||
|
Competitions: competitions,
|
||||||
|
}
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
json.NewEncoder(w).Encode(clubInfo)
|
||||||
|
}
|
||||||
|
|
||||||
|
// getClubInfo returns club info with competitions and matches
|
||||||
|
func getClubInfo(w http.ResponseWriter, r *http.Request) {
|
||||||
|
vars := mux.Vars(r)
|
||||||
|
clubID := vars["id"]
|
||||||
|
clubType := vars["type"]
|
||||||
|
if clubID == "" {
|
||||||
|
http.Error(w, "Club ID is required", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var baseURL, sportParam string
|
||||||
|
switch clubType {
|
||||||
|
case "football":
|
||||||
|
baseURL = "https://www.fotbal.cz/souteze/club/club"
|
||||||
|
sportParam = "fotbal"
|
||||||
|
case "futsal":
|
||||||
|
baseURL = "https://www.fotbal.cz/futsal/club/club"
|
||||||
|
sportParam = "futsal"
|
||||||
|
default:
|
||||||
|
http.Error(w, "Invalid club type. Use 'football' or 'futsal'.", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
url := fmt.Sprintf("%s/%s", baseURL, clubID)
|
||||||
|
resp, err := http.Get(url)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, fmt.Sprintf("Error fetching club data: %v", err), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
http.Error(w, fmt.Sprintf("Error: received status code %d", resp.StatusCode), resp.StatusCode)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
doc, err := goquery.NewDocumentFromReader(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, fmt.Sprintf("Error parsing HTML: %v", err), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
clubName := strings.TrimSpace(doc.Find("h1.H4 span").First().Text())
|
||||||
|
// Basic club metadata
|
||||||
|
clubURL := fmt.Sprintf("%s/%s", baseURL, clubID)
|
||||||
|
logoURL := fmt.Sprintf("https://is1.fotbal.cz/media/kluby/%s/%s_crop.jpg", clubID, clubID)
|
||||||
|
category := "Fotbal"
|
||||||
|
if strings.EqualFold(clubType, "futsal") {
|
||||||
|
category = "Futsal"
|
||||||
|
}
|
||||||
|
// Internal ID
|
||||||
|
clubInternalID := ""
|
||||||
|
doc.Find("section").Each(func(_ int, s *goquery.Selection) {
|
||||||
|
if strings.TrimSpace(s.Find("h3 span").First().Text()) == "ID klubu" {
|
||||||
|
clubInternalID = strings.TrimSpace(s.Find("ul li").First().Text())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// Address (best-effort)
|
||||||
|
address := strings.TrimSpace(doc.Find(".ClubAddress p").First().Text())
|
||||||
|
|
||||||
|
// Competitions list
|
||||||
|
var competitions []Competition
|
||||||
|
doc.Find("table.Table tbody tr").Each(func(_ int, tr *goquery.Selection) {
|
||||||
|
code := strings.TrimSpace(tr.Find("td:first-child").Text())
|
||||||
|
nameLink := tr.Find("td:nth-child(2) a")
|
||||||
|
name := strings.TrimSpace(nameLink.Text())
|
||||||
|
teamCount := strings.TrimSpace(tr.Find("td:nth-child(3)").Text())
|
||||||
|
parts := strings.Split(strings.TrimSpace(nameLink.AttrOr("href", "")), "/")
|
||||||
|
compID := ""
|
||||||
|
if len(parts) >= 2 {
|
||||||
|
compID = parts[len(parts)-1]
|
||||||
|
}
|
||||||
|
// Public table URL for convenience
|
||||||
|
tableLink := ""
|
||||||
|
if strings.EqualFold(clubType, "futsal") {
|
||||||
|
tableLink = fmt.Sprintf("https://www.fotbal.cz/futsal/futsal/table/%s", compID)
|
||||||
|
} else {
|
||||||
|
tableLink = fmt.Sprintf("https://www.fotbal.cz/souteze/turnaje/table/%s", compID)
|
||||||
|
}
|
||||||
|
competitions = append(competitions, Competition{ID: compID, Code: code, Name: name, TeamCount: teamCount, MatchesLink: tableLink})
|
||||||
|
})
|
||||||
|
|
||||||
|
// For each competition, fetch matches
|
||||||
|
for i := range competitions {
|
||||||
|
comp := &competitions[i]
|
||||||
|
detailURL := fmt.Sprintf("https://is.fotbal.cz/public/souteze/detail-souteze.aspx?req=%s&sport=%s", comp.ID, sportParam)
|
||||||
|
resp, err := http.Get(detailURL)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("error fetching competition detail for %s: %v", comp.ID, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
log.Printf("non-200 response for %s: %d", comp.ID, resp.StatusCode)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
docDetail, err := goquery.NewDocumentFromReader(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("error parsing competition HTML for %s: %v", comp.ID, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
var matches []Match
|
||||||
|
docDetail.Find("table.soutez-zapasy tr").Each(func(_ int, s *goquery.Selection) {
|
||||||
|
if s.Find("th").Length() > 0 { // skip header
|
||||||
|
return
|
||||||
|
}
|
||||||
|
tds := s.Find("td")
|
||||||
|
if tds.Length() < 7 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
getText := func(sel *goquery.Selection) string { return strings.TrimSpace(sel.Text()) }
|
||||||
|
dt := getText(tds.Eq(0))
|
||||||
|
rawHome := getText(tds.Eq(1))
|
||||||
|
if idx := strings.Index(rawHome, "("); idx >= 0 {
|
||||||
|
rawHome = strings.TrimSpace(rawHome[:idx])
|
||||||
|
}
|
||||||
|
rawAway := getText(tds.Eq(2))
|
||||||
|
if idx := strings.Index(rawAway, "("); idx >= 0 {
|
||||||
|
rawAway = strings.TrimSpace(rawAway[:idx])
|
||||||
|
}
|
||||||
|
homeID := extractUUIDFromHref(tds.Eq(1).Find("a").First().AttrOr("href", ""))
|
||||||
|
awayID := extractUUIDFromHref(tds.Eq(2).Find("a").First().AttrOr("href", ""))
|
||||||
|
rawScore := getText(tds.Eq(3))
|
||||||
|
score := ""
|
||||||
|
if re := regexp.MustCompile(`(\d+)\s*:\s*(\d+)`); re != nil {
|
||||||
|
if m := re.FindStringSubmatch(rawScore); len(m) == 3 {
|
||||||
|
score = fmt.Sprintf("%s:%s", m[1], m[2])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
venue := getText(tds.Eq(4))
|
||||||
|
note := ""
|
||||||
|
var reportURL, matchID string
|
||||||
|
tds.Eq(6).Find("a").Each(func(_ int, a *goquery.Selection) {
|
||||||
|
href := strings.TrimSpace(a.AttrOr("href", ""))
|
||||||
|
if href == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if u, err := neturl.Parse(href); err == nil {
|
||||||
|
if id := u.Query().Get("zapas"); id != "" {
|
||||||
|
matchID = id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if matchID != "" {
|
||||||
|
if strings.EqualFold(clubType, "futsal") {
|
||||||
|
reportURL = fmt.Sprintf("https://www.fotbal.cz/futsal/zapasy/futsal/%s", matchID)
|
||||||
|
} else {
|
||||||
|
reportURL = fmt.Sprintf("https://www.fotbal.cz/souteze/zapasy/zapas/%s", matchID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if clubName != "" {
|
||||||
|
involved := strings.EqualFold(rawHome, clubName) || strings.EqualFold(rawAway, clubName) ||
|
||||||
|
containsFold(clubName, rawHome) || containsFold(clubName, rawAway) ||
|
||||||
|
containsFold(rawHome, clubName) || containsFold(rawAway, clubName)
|
||||||
|
if !involved {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Compose logo URLs for both teams when IDs are available
|
||||||
|
homeLogo := getLogo(rawHome, homeID)
|
||||||
|
awayLogo := getLogo(rawAway, awayID)
|
||||||
|
matches = append(matches, Match{DateTime: dt, Home: rawHome, HomeID: homeID, HomeLogoURL: homeLogo, Away: rawAway, AwayID: awayID, AwayLogoURL: awayLogo, Score: score, Venue: venue, Note: note, MatchID: matchID, ReportURL: reportURL})
|
||||||
|
})
|
||||||
|
comp.Matches = matches
|
||||||
|
}
|
||||||
|
|
||||||
|
clubInfo := ClubInfo{
|
||||||
|
Name: clubName,
|
||||||
|
ClubID: clubID,
|
||||||
|
ClubType: clubType,
|
||||||
|
ClubInternalID: clubInternalID,
|
||||||
|
URL: clubURL,
|
||||||
|
LogoURL: logoURL,
|
||||||
|
Address: address,
|
||||||
|
Category: category,
|
||||||
|
Competitions: competitions,
|
||||||
|
}
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
json.NewEncoder(w).Encode(clubInfo)
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
r := mux.NewRouter()
|
||||||
|
r.HandleFunc("/club/{type}/{id}", getClubInfo).Methods("GET")
|
||||||
|
r.HandleFunc("/club/{type}/{id}/table", getClubTables).Methods("GET")
|
||||||
|
r.HandleFunc("/club/search", getClubSearch).Methods("GET")
|
||||||
|
r.HandleFunc("/club/{id:[0-9a-fA-F-]+}", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
vars := mux.Vars(r)
|
||||||
|
http.Redirect(w, r, "/club/football/"+vars["id"], http.StatusMovedPermanently)
|
||||||
|
}).Methods("GET")
|
||||||
|
r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
w.Write([]byte(`{"status":"ok","message":"FACR Scraper API is running"}`))
|
||||||
|
})
|
||||||
|
port := ":8080"
|
||||||
|
fmt.Printf("Server running on http://localhost%s\n", port)
|
||||||
|
log.Fatal(http.ListenAndServe(port, r))
|
||||||
|
}
|
||||||
|
|
||||||
|
// containsFold returns true if substr is within s, case-insensitive.
|
||||||
|
func containsFold(s, substr string) bool {
|
||||||
|
s = strings.ToLower(strings.TrimSpace(s))
|
||||||
|
substr = strings.ToLower(strings.TrimSpace(substr))
|
||||||
|
if substr == "" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return strings.Contains(s, substr)
|
||||||
|
}
|
||||||
|
|
||||||
|
// extractUUIDFromHref finds the first UUID-like token in an href and returns it.
|
||||||
|
func extractUUIDFromHref(href string) string {
|
||||||
|
href = strings.TrimSpace(href)
|
||||||
|
if href == "" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
re := regexp.MustCompile(`[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}`)
|
||||||
|
if m := re.FindString(href); m != "" {
|
||||||
|
return m
|
||||||
|
}
|
||||||
|
// Fallback: some links may end with ID after slash; take last path token if it looks like hex+hyphenated
|
||||||
|
parts := strings.Split(href, "/")
|
||||||
|
if len(parts) > 0 {
|
||||||
|
cand := parts[len(parts)-1]
|
||||||
|
if re.MatchString(cand) {
|
||||||
|
return cand
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
type Match struct {
|
||||||
|
DateTime string `json:"date_time"`
|
||||||
|
Home string `json:"home"`
|
||||||
|
HomeID string `json:"home_id,omitempty"`
|
||||||
|
HomeLogoURL string `json:"home_logo_url,omitempty"`
|
||||||
|
Away string `json:"away"`
|
||||||
|
AwayID string `json:"away_id,omitempty"`
|
||||||
|
AwayLogoURL string `json:"away_logo_url,omitempty"`
|
||||||
|
Score string `json:"score"`
|
||||||
|
Venue string `json:"venue"`
|
||||||
|
Note string `json:"note,omitempty"`
|
||||||
|
MatchID string `json:"match_id"`
|
||||||
|
ReportURL string `json:"report_url,omitempty"`
|
||||||
|
DelegationURL string `json:"delegation_url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TableRow represents one row in a standings table
|
||||||
|
type TableRow struct {
|
||||||
|
Rank string `json:"rank"`
|
||||||
|
Team string `json:"team"`
|
||||||
|
TeamID string `json:"team_id,omitempty"`
|
||||||
|
TeamLogoURL string `json:"team_logo_url,omitempty"`
|
||||||
|
Played string `json:"played"`
|
||||||
|
Wins string `json:"wins"`
|
||||||
|
Draws string `json:"draws"`
|
||||||
|
Losses string `json:"losses"`
|
||||||
|
Score string `json:"score"`
|
||||||
|
Points string `json:"points"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// resolveISURL makes relative IS links absolute against https://is.fotbal.cz/public/
|
||||||
|
func resolveISURL(href string) string {
|
||||||
|
href = strings.TrimSpace(href)
|
||||||
|
if strings.HasPrefix(href, "http://") || strings.HasPrefix(href, "https://") {
|
||||||
|
if u, err := neturl.Parse(href); err == nil {
|
||||||
|
u.Scheme = "https"
|
||||||
|
u.Host = "is.fotbal.cz"
|
||||||
|
if !strings.HasPrefix(u.Path, "/public/") {
|
||||||
|
if strings.HasPrefix(u.Path, "/zapasy/") {
|
||||||
|
u.Path = "/public" + u.Path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
q := u.Query()
|
||||||
|
q.Del("discipline")
|
||||||
|
u.RawQuery = q.Encode()
|
||||||
|
return u.String()
|
||||||
|
}
|
||||||
|
return href
|
||||||
|
}
|
||||||
|
href = strings.TrimPrefix(href, "./")
|
||||||
|
for strings.HasPrefix(href, "../") {
|
||||||
|
href = strings.TrimPrefix(href, "../")
|
||||||
|
}
|
||||||
|
if strings.HasPrefix(href, "/") {
|
||||||
|
href = strings.TrimPrefix(href, "/")
|
||||||
|
}
|
||||||
|
path := "/public/" + href
|
||||||
|
u := neturl.URL{Scheme: "https", Host: "is.fotbal.cz", Path: path}
|
||||||
|
return u.String()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user