fork download
  1. import re
  2. import json
  3.  
  4. content = """
  5. curl -o output.txt http://e...content-available-to-author-only...e.com
  6. curl https://h...content-available-to-author-only...t.us/400 -f
  7. curl http://e...content-available-to-author-only...e.sh | bash
  8. curl ftp://e...content-available-to-author-only...e.sh | sudo bash
  9. curl www.helloworld.com > test.file
  10. curl -X 'GET' 'http://localhost:8000' -H 'accept: application/json'
  11.  
  12. curl -s https://p...content-available-to-author-only...d.io/install/repositories/github/git-lfs/script.deb.sh | bash
  13. curl -X 'GET' 'http://localhost:8000' -H 'application/json'
  14. curl -X 'GET' "http://localhost:8000" -H 'application/json'
  15. RUN curl --user "APITest:API.User" https://s...content-available-to-author-only...e.com/api/REST/1.0/data/contacts?count=2
  16. curl --header "Content-Type: application/json" -d '{"emailAddress":"george.washington@america.com"}' https://s...content-available-to-author-only...e.com/api/REST/1.0/data/contact
  17. curl -X GET -H "Authorization: Bearer {ACCESS_TOKEN}" "https://a...content-available-to-author-only...r.io/posts"
  18. curl --user "<companyName>:<userName>" --request GET https://secure.p0<podNumber>.eloqua.com/api/<apiType>/<apiVersion>/<endpoint>
  19. curl --user "APITest:API.User" --header "Content-Type: application/json" --request POST --data '{"emailAddress":"george.washington@america.com"}' https://s...content-available-to-author-only...e.com/api/REST/1.0/data/contact
  20. curl --user "APITest:API.User" --header "Content-Type: application/json" --request PUT --data '{"id":"1","emailAddress":"george.washington@america.com","businessPhone":"555-555-5555"}' https://s...content-available-to-author-only...e.com/api/REST/1.0/data/contact/1
  21. """
  22.  
  23. curl_extractor_regex = re.compile(r'\bcurl\s.*(?:-X|--(?:header|user)\b).*')
  24. data = curl_extractor_regex.findall(content)
  25. print(json.dumps(data, indent=4))
Success #stdin #stdout 0.03s 9800KB
stdin
Standard input is empty
stdout
[
    "curl -X 'GET' 'http://localhost:8000' -H 'accept: application/json'",
    "curl -X 'GET' 'http://localhost:8000' -H 'application/json'",
    "curl -X 'GET' \"http://localhost:8000\" -H 'application/json'",
    "curl --user \"APITest:API.User\" https://s...content-available-to-author-only...e.com/api/REST/1.0/data/contacts?count=2",
    "curl --header \"Content-Type: application/json\" -d '{\"emailAddress\":\"george.washington@america.com\"}' https://s...content-available-to-author-only...e.com/api/REST/1.0/data/contact",
    "curl -X GET -H \"Authorization: Bearer {ACCESS_TOKEN}\" \"https://a...content-available-to-author-only...r.io/posts\"",
    "curl --user \"<companyName>:<userName>\" --request GET https://secure.p0<podNumber>.eloqua.com/api/<apiType>/<apiVersion>/<endpoint>",
    "curl --user \"APITest:API.User\" --header \"Content-Type: application/json\" --request POST --data '{\"emailAddress\":\"george.washington@america.com\"}' https://s...content-available-to-author-only...e.com/api/REST/1.0/data/contact",
    "curl --user \"APITest:API.User\" --header \"Content-Type: application/json\" --request PUT --data '{\"id\":\"1\",\"emailAddress\":\"george.washington@america.com\",\"businessPhone\":\"555-555-5555\"}' https://s...content-available-to-author-only...e.com/api/REST/1.0/data/contact/1"
]