Comments (6)
@asciimoo, it works for me too.
I should have tried to post with the trailing slash.
Thanks so much. 👍
from colly.
grequests could be used to submit forms, process file uploads, etc.
from colly.
Colly supports the requested features. It handles cookies automatically and has functions to send form data:
- https://godoc.org/github.com/asciimoo/colly#Collector.Post
- https://godoc.org/github.com/asciimoo/colly#Collector.PostMultipart
from colly.
Perfect! Thanks for posting the links.
from colly.
@asciimoo, could you explain how can I send FormData:
The following requests with the following params returns 500 rows proxy list (http://spys.one/en/http-proxy-list).
I've experimented with the following ways:
Click to expand
// 1
collector.PostRaw(
"http://spys.one/en/http-proxy-list",
[]byte(
fmt.Sprintf("xpp:5\r\nxf1:0\r\nxf2:2\r\nxf4:2\r\nxf5:1"),
),
)
// 2
formData := map[string]string{
"xpp": "5",
"xf1": "0",
"xf2": "2",
"xf4": "2",
"xf5": "1",
}
form := url.Values{}
for k, v := range formData {
form.Add(k, v)
}
collector.PostRaw(
"http://spys.one/en/http-proxy-list",
[]byte(form.Encode()),
)
// 3
collector.Post(
"http://spys.one/en/http-proxy-list",
map[string]string{
"xpp": "5",
"xf1": "0",
"xf2": "2",
"xf4": "2",
"xf5": "1",
},
)
// 4
collector.PostMultipart(
"http://spys.one/en/http-proxy-list",
map[string][]byte{
"xpp": []byte("5"),
"xf1": []byte("0"),
"xf2": []byte("2"),
"xf4": []byte("5"),
"xf5": []byte("1"),
},
)
// 5
form := url.Values{}
form.Set("xpp", "5")
form.Add("xf1", "0")
form.Add("xf2", "2")
form.Add("xf4", "5")
form.Add("xf5", "1")
formEncoded := form.Encode()
collector.Request(
"POST",
"http://spys.one/en/http-proxy-list",
strings.NewReader(formEncoded),
nil,
nil,
)
But they return 30 rows proxy list. Looks like those params are ignored.
from colly.
It works for me if I append the trailing slash to the end of the URL like in your screenshot:
package main
import (
"fmt"
"github.com/gocolly/colly"
)
func main() {
c := colly.NewCollector()
c.OnHTML("tr.spy1x,tr.spy1xx", func(e *colly.HTMLElement) {
fmt.Println(e)
})
fmt.Println(c.Post(
"http://spys.one/en/http-proxy-list/",
map[string]string{
"xpp": "5",
"xf1": "0",
"xf2": "0",
"xf4": "0",
"xf5": "0",
},
))
}
from colly.
Related Issues (20)
- Colly has vulnerabilities with medium criticality HOT 4
- Fetching data that is not coming in curl output HOT 1
- SIGSEG on local files HOT 1
- Misleading Request.Depth documentation HOT 1
- I have a request that I don't know how to make using Colly. HOT 1
- Different MaxDepth on AllowedDomains and others ? HOT 3
- Is there a way spider for "https://netbanking.hdfcbank.com/netbanking" with my owner account? HOT 1
- HTML encoding is not autodetected properly HOT 6
- request chan error HOT 1
- Cannot send request with no Accept header HOT 1
- handleOnXML tries to parse`.xlsx` files HOT 2
- Next release - When?
- Duplicated requests HOT 1
- How to handle selector not found?
- how to by pass c.OnError HOT 1
- Post Login not persist session
- Weird async behaviour - duplicates in responses HOT 1
- Support BFS search .
- retry redirect to AlreadyVisitedUrl will loop error HOT 1
- Error trying to conditionally set up proxy function HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from colly.