tcgplayer_spider.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # -*- coding: utf-8 -*-
  2. # Author : Charley
  3. # Python : 3.10.8
  4. # Date : 2025/10/30 14:56
  5. import requests
  6. import json
  7. headers = {
  8. "accept": "application/json, text/plain, */*",
  9. "content-type": "application/json",
  10. "referer": "https://www.tcgplayer.com/",
  11. "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36"
  12. }
  13. url = "https://mp-search-api.tcgplayer.com/v1/search/request"
  14. params = {
  15. "q": "",
  16. "isList": "false",
  17. "mpfev": "4448"
  18. }
  19. data = {
  20. "algorithm": "sales_dismax",
  21. "from": 4776,
  22. "size": 24,
  23. "filters": {
  24. "term": {
  25. "productLineName": [
  26. "magic"
  27. ],
  28. "setName": [
  29. "the-list-reprints"
  30. ],
  31. "productTypeName": [
  32. "Cards"
  33. ]
  34. },
  35. "range": {},
  36. "match": {}
  37. },
  38. "listingSearch": {
  39. "context": {
  40. "cart": {}
  41. },
  42. "filters": {
  43. "term": {
  44. "sellerStatus": "Live",
  45. "channelId": 0
  46. },
  47. "range": {
  48. "quantity": {
  49. "gte": 1
  50. }
  51. },
  52. "exclude": {
  53. "channelExclusion": 0
  54. }
  55. }
  56. },
  57. "context": {
  58. "cart": {},
  59. "shippingCountry": "CN",
  60. "userProfile": {}
  61. },
  62. "settings": {
  63. "useFuzzySearch": True,
  64. "didYouMean": {}
  65. },
  66. "sort": {}
  67. }
  68. data = json.dumps(data, separators=(',', ':'))
  69. response = requests.post(url, headers=headers, params=params, data=data)
  70. print(response.text)
  71. print(response)